|
15 | 15 | | MultiLineString | done | |
16 | 16 | | Polygon | done | |
17 | 17 | | MultiPolygon | done | |
18 | | -| GeometryCollection | in progress | |
| 18 | +| GeometryCollection | done | |
19 | 19 | | Feature | in progress | |
20 | 20 | | FeatureCollection | in progress | |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +To generate fake geodata, you can use both methods and a special class `GeoJsonFaker`. |
| 25 | + |
| 26 | +Example of generation a random `Point` using the `fake_point` method: |
| 27 | + |
| 28 | +```python |
| 29 | +>>> from geojson_faker import fake_point, Dimension |
| 30 | +>>> # Point2D or Point3D |
| 31 | +>>> fake_point() |
| 32 | +Point(bbox=None, type='Point', coordinates=Position2D(longitude=-97.30689091127957, latitude=56.891859157037686)) |
| 33 | +>>> fake_point() |
| 34 | +Point(bbox=None, type='Point', coordinates=Position3D(longitude=-23.91579574348077, latitude=-29.49843686198053, altitude=38061.79569985675)) |
| 35 | +>>> # Point2D |
| 36 | +>>> fake_point(dimension=Dimension.two) |
| 37 | +Point(bbox=None, type='Point', coordinates=Position2D(longitude=-165.04984397840835, latitude=76.97108937919282)) |
| 38 | +>>> # Point3D |
| 39 | +>>> fake_point(dimension=Dimension.three) |
| 40 | +Point(bbox=None, type='Point', coordinates=Position3D(longitude=-118.39348949345089, latitude=27.81106033708747, altitude=8475.464707933897)) |
| 41 | +``` |
| 42 | + |
| 43 | +Example of generation using the class: |
| 44 | + |
| 45 | +```python |
| 46 | +>>> from geojson_faker import GeoJsonFaker |
| 47 | +>>> geojson_faker = GeoJsonFaker() |
| 48 | +>>> # Point2D or Point3D |
| 49 | +>>> geojson_faker.point |
| 50 | +Point(bbox=None, type='Point', coordinates=Position2D(longitude=-50.56703965217093, latitude=19.72513434718111)) |
| 51 | +>>> geojson_faker.point |
| 52 | +Point(bbox=None, type='Point', coordinates=Position3D(longitude=111.84911865610678, latitude=-19.488979926988165, altitude=7921.968274391678)) |
| 53 | +>>> # Point2D |
| 54 | +>>> geojson_faker.point2d |
| 55 | +Point(bbox=None, type='Point', coordinates=Position2D(longitude=29.98434638920918, latitude=36.476444735501616)) |
| 56 | +>>> # Point3D |
| 57 | +>>> geojson_faker.point3d |
| 58 | +Point(bbox=None, type='Point', coordinates=Position3D(longitude=-76.36126084558762, latitude=30.682266859380533, altitude=15816.987234147065)) |
| 59 | +``` |
| 60 | + |
| 61 | +The class has some advantages, so I would recommend using it preferably. |
| 62 | + |
| 63 | +### Random always |
| 64 | + |
| 65 | +The `random_always` setting allows you to specify whether to generate random data permanently or to remember the last result and reuse it. |
| 66 | + |
| 67 | +An example with `Point`: |
| 68 | + |
| 69 | +```python |
| 70 | +>>> from geojson_faker import GeoJsonFaker |
| 71 | +>>> # random_always is True by default |
| 72 | +>>> geojson_faker = GeoJsonFaker() |
| 73 | +>>> geojson_faker.point |
| 74 | +Point(bbox=None, type='Point', coordinates=Position2D(longitude=136.68932246536838, latitude=-69.51345731343906)) |
| 75 | +>>> geojson_faker.point |
| 76 | +Point(bbox=None, type='Point', coordinates=Position3D(longitude=-86.5130499597834, latitude=-32.985220372899015, altitude=39772.673364264505)) |
| 77 | +>>> |
| 78 | +>>> # Set random_always to False |
| 79 | +>>> geojson_faker = GeoJsonFaker(random_always=False) |
| 80 | +>>> geojson_faker.point |
| 81 | +Point(bbox=None, type='Point', coordinates=Position3D(longitude=-124.54510003846121, latitude=25.225529991773328, altitude=-423.45973067919476)) |
| 82 | +>>> geojson_faker.point |
| 83 | +Point(bbox=None, type='Point', coordinates=Position3D(longitude=-124.54510003846121, latitude=25.225529991773328, altitude=-423.45973067919476)) |
| 84 | +``` |
0 commit comments