Skip to content

Commit 706a833

Browse files
committed
docs: update readme
1 parent e87e957 commit 706a833

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

geojson_faker/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
fake_polygon,
1313
fake_position,
1414
)
15+
from geojson_faker.types import Dimension
1516

1617
__version__ = "0.3.0"
1718

@@ -28,4 +29,5 @@
2829
"fake_polygon",
2930
"fake_multi_polygon",
3031
"fake_geometry_collection",
32+
"Dimension",
3133
]

readme.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,70 @@
1515
| MultiLineString | done |
1616
| Polygon | done |
1717
| MultiPolygon | done |
18-
| GeometryCollection | in progress |
18+
| GeometryCollection | done |
1919
| Feature | in progress |
2020
| 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

Comments
 (0)