Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/omanges/turfpy
Browse files Browse the repository at this point in the history
  • Loading branch information
omanges committed Jul 24, 2021
2 parents 5aa9ffa + 683965f commit 15ec214
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ A Python library for performing geospatial data analysis which reimplements `tur

Line Intersect <misc/line_intersect>
Line Segment <misc/line_segment>
Line Arc <misc/line_arc>
Sector <misc/sector>

.. toctree::
:maxdepth: 1
Expand Down
46 changes: 46 additions & 0 deletions docs/source/misc/line_arc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Line Arc
================
Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.

Example
-------

.. jupyter-execute::

from turfpy.misc import line_arc
from geojson import Feature, Point

center = Feature(geometry=Point((-75, 40)))
radius = 5
bearing1 = 25
bearing2 = 47

line_arc(center=center, radius=radius, bearing1=bearing1, bearing2=bearing2)



Interactive Example
-------------------

.. jupyter-execute::

from ipyleaflet import Map, GeoJSON, LayersControl
from turfpy.misc import line_arc
from geojson import Feature, Point, LineString, FeatureCollection

center = Feature(geometry=Point((-75, 40)))
radius = 5;
bearing1 = 25;
bearing2 = 47;

m = Map(center=[40.011313056309056, -74.97720068362348], zoom=12)

feature = line_arc(center=center, radius=radius, bearing1=bearing1, bearing2=bearing2)

fc = FeatureCollection([feature, center])

layer = GeoJSON(name="Line_Arc", data=fc, style={'color':'red'})

m.add_layer(layer)
m

47 changes: 47 additions & 0 deletions docs/source/misc/sector.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Sector
================
Creates a circular sector of a circle of given radius and center Point, between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.

Example
-------

.. jupyter-execute::

from turfpy.misc import sector
from geojson import Feature, Point

center = Feature(geometry=Point((-75, 40)))
radius = 5
bearing1 = 25
bearing2 = 45

feature = sector(center, radius, bearing1, bearing2, options={"properties":{"length":3}})



Interactive Example
-------------------

.. jupyter-execute::

from ipyleaflet import Map, GeoJSON, LayersControl
from turfpy.misc import sector
from geojson import Feature, Point, LineString, FeatureCollection

center = Feature(geometry=Point((-75, 40)))
radius = 5;
bearing1 = 25;
bearing2 = 45;

m = Map(center=[40.011313056309056, -74.97720068362348], zoom=12)

feature = sector(center, radius, bearing1, bearing2, options={"properties":{"length":3}})


fc = FeatureCollection([feature, center])

layer = GeoJSON(name="Line_Arc", data=fc, style={'color':'red'})

m.add_layer(layer)
m

52 changes: 51 additions & 1 deletion examples/Misc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,56 @@
"\n",
"line_segment(poly)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Line Arc\n",
"Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2; 0 bearing is North of center point, positive clockwise."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from turfpy.misc import line_arc\n",
"from geojson import Feature, Point\n",
"\n",
"center = Feature(geometry=Point((-75, 40)))\n",
"radius = 5\n",
"bearing1 = 25\n",
"bearing2 = 47\n",
"\n",
"line_arc(center=center, radius=radius, bearing1=bearing1, bearing2=bearing2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sector\n",
"Creates a circular sector of a circle of given radius and center Point, between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from turfpy.misc import sector\n",
"from geojson import Feature, Point\n",
"\n",
"center = Feature(geometry=Point((-75, 40)))\n",
"radius = 5\n",
"bearing1 = 25\n",
"bearing2 = 45\n",
"\n",
"feature = sector(center, radius, bearing1, bearing2, options={\"properties\":{\"length\":3}})"
]
}
],
"metadata": {
Expand All @@ -93,7 +143,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down
57 changes: 57 additions & 0 deletions misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,60 @@ poly = {

line_segment(poly)
```

* Line Arc : Creates a circular arc, of a circle of the given radius and center point,
between bearing1 and bearing2; 0 bearing is
North of center point, positive clockwise.

| Argument | Type | Description |
| ------- | ------ | ----------- |
| `center` | Feature | A `Point` object representing center point of circle |
| `radius` | float | An int representing radius of the circle |
| `bearing1` | float | Angle, in decimal degrees, of the first radius of the arc |
| `bearing2` | float | Angle, in decimal degrees, of the second radius of the arc |
| `options` | float | A dict representing additional properties,which can be `steps` which has default values as 64 and `units` which has default values of `km` |

| Return | Type | Description |
| ------- | ------ | ----------- |
| `line string` | Feature | A Line String feature object. |

```python
from turfpy.misc import line_arc
from geojson import Feature, Point

center = Feature(geometry=Point((-75, 40)))
radius = 5
bearing1 = 25
bearing2 = 47

line_arc(center=center, radius=radius, bearing1=bearing1, bearing2=bearing2)
```


* Line Arc : Creates a circular sector of a circle of given radius and center Point ,
between (clockwise) bearing1 and bearing2; 0
bearing is North of center point, positive clockwise.

| Argument | Type | Description |
| ------- | ------ | ----------- |
| `center` | Feature | A `Point` object representing center point of circle |
| `radius` | float | An int representing radius of the circle |
| `bearing1` | float | Angle, in decimal degrees, of the first radius of the arc |
| `bearing2` | float | Angle, in decimal degrees, of the second radius of the arc |
| `options` | float | A dict representing additional properties, which can be `steps` which has default values as 64, `units` which has default values of `km`, and `properties` which will be added to resulting Feature as properties. |

| Return | Type | Description |
| ------- | ------ | ----------- |
| `polygon` | Feature | A polygon feature object. |

```python
from turfpy.misc import sector
from geojson import Feature, Point

center = Feature(geometry=Point((-75, 40)))
radius = 5
bearing1 = 25
bearing2 = 45

feature = sector(center, radius, bearing1, bearing2, options={"properties":{"length":3}})
```
2 changes: 1 addition & 1 deletion turfpy/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Project version information."""

__version__ = "0.0.6"
__version__ = "0.0.7"
7 changes: 7 additions & 0 deletions turfpy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,10 @@ def radians_to_degrees(radians: float):
"""#TODO: Add description"""
degrees = abs(radians) % (2 * math.pi) * (1 if radians >= 0 else -1)
return degrees * 180 / math.pi


def convert_angle_to_360(alfa: float):
beta = alfa % 360
if beta < 0:
beta += 360
return beta
1 change: 1 addition & 0 deletions turfpy/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ def _callback_feature_each(pt, feature_index):
if float(distance_to_point) < min_dist:
best_feature_index = feature_index
min_dist = distance_to_point
return True

feature_each(points, _callback_feature_each)

Expand Down
Loading

0 comments on commit 15ec214

Please sign in to comment.