Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize v0.1.7 #31

Merged
merged 28 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
de1f368
Updating release guide
smmaurer Aug 14, 2020
dce59a3
Merge pull request #25 from UDST/fix-wheel
smmaurer Aug 17, 2020
d2fd5f0
fix DeprecationWarning for re.findall()
sablanchard Apr 1, 2021
6706683
refactor project_geometry() and update for CRS FutureWarning
sablanchard Apr 1, 2021
0282c8d
update docstrings and FutureWarning for CRS init schema change
sablanchard Apr 1, 2021
0b066b8
update unit tests to use equals() to fix FutureWarning on use of pdt.…
sablanchard Apr 1, 2021
b7e23cd
add unit test for project_geometry() and unit test update imports
sablanchard Apr 1, 2021
90e4e51
formatting fixes for pycodestyle
sablanchard Apr 1, 2021
0e612d7
bump up requirements
sablanchard Apr 1, 2021
6690afa
update contribution guidelines
sablanchard Apr 1, 2021
d420b76
drop 3.7 tests
sablanchard Apr 1, 2021
bcfc5d9
set geopandas req version to 0.8.2
sablanchard Apr 1, 2021
f52744c
update PyPI contribution line
sablanchard Apr 1, 2021
eaad726
set req for shapely >= 1.6
sablanchard Apr 1, 2021
0c5af00
Merge pull request #27 from UDST/maintenance/depreciation-futurewarn-…
smmaurer Apr 6, 2021
023c3c4
bump up license year and update readme/docs
sablanchard Oct 11, 2022
3b1fe1a
add python 3.9 and 10 to supported python versions
sablanchard Oct 11, 2022
ad4c117
updates for shapely depreciated iterating over multi-part geometries,…
sablanchard Oct 11, 2022
3658784
update unit tests to match results of the latest osm test data pulls
sablanchard Oct 11, 2022
5376d05
minor update to docs
sablanchard Oct 13, 2022
e1ab4df
Merge pull request #29 from UDST/maintenance/python-version-shapely-dep
smmaurer Aug 2, 2023
dde9017
Versioning
smmaurer Aug 2, 2023
598aed6
Python version support
smmaurer Aug 2, 2023
3fd5f6c
update unit tests to match results of the latest osm test data pulls
sablanchard Aug 2, 2023
035bafd
Update travis
smmaurer Aug 2, 2023
8d06f35
Cleanup
smmaurer Aug 7, 2023
1ba50a8
Cleanup
smmaurer Aug 7, 2023
47cfec0
Merge pull request #30 from UDST/release-prep
smmaurer Aug 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: python

python:
- '3.5'
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'

install:
- pip install .
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.1.7
======

2023/8/7

* adds support for Shapely 2.0

v0.1.6
======

Expand Down
59 changes: 42 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,67 @@
## If you have found an error:
Thanks for using OSMnet!

- check the error message and [documentation](https://udst.github.io/osmnet/index.html)
- search the previously opened and closed issues to see if the problem has already been reported
- if the problem is with a dependency of OSMnet, please open an issue on the dependency's repo
- if the problem is with OSMnet and you think you may have a fix, please submit a PR, otherwise please open an issue in the [issue tracker](https://github.com/UDST/osmnet/issues) following the issue template
This is an open source project that's part of the Urban Data Science Toolkit. Development and maintenance is a collaboration between UrbanSim Inc, U.C. Berkeley's Urban Analytics Lab, and other contributors.

## Making a feature proposal or contributing code:
## If you have a problem:

- Take a look at the [open issues](https://github.com/UDST/osmnet/issues) and [closed issues](https://github.com/UDST/osmnet/issues?q=is%3Aissue+is%3Aclosed) to see if there's already a related discussion

- Open a new issue describing the problem -- if possible, include any error messages, a full reproducible example of the code that generated the error, the operating system and version of Python you're using, and versions of any libraries that may be relevant

## Feature proposals:

- Take a look at the [open issues](https://github.com/UDST/osmnet/issues) and [closed issues](https://github.com/UDST/osmnet/issues?q=is%3Aissue+is%3Aclosed) to see if there's already a related discussion

- Post your proposal as a new issue, so we can discuss it (some proposals may not be a good fit for the project)

## Contributing code:

- Create a new branch of `UDST/osmnet/dev`, or fork the repository to your own account

- Make your changes, following the existing styles for code and inline documentation

- Add [tests](https://github.com/UDST/osmnet/tree/dev/osmnet/tests) if possible
- We use the test suite: Pytest

- Run tests and address any issues that may be flagged. If flags are raised that are not due to the PR note that in a new comment in the PR
- Run Pytest test suite: `py.test`
- OSMnet currently supports Python 3.5, 3.6, 3.7, 3.8. Tests will be run in these environments when the PR is created but any flags raised in these environments should also be addressed
- Run pycodestyle Python style guide checker: `pycodestyle --max-line-length=100 osmnet`

- Open a pull request to the `UDST/osmnet` `dev` branch, including a writeup of your changes -- take a look at some of the closed PR's for examples

- Current maintainers will review the code, suggest changes, and hopefully merge it and schedule it for an upcoming release

- post your requested feature on the [issue tracker](https://github.com/UDST/osmnet/issues) and mark it with a `New feature` label so it can be reviewed
- fork the repo, make your change (your code should attempt to conform to OSMnet's existing coding, commenting, and docstring styles), add new or update [unit tests](https://github.com/UDST/osmnet/tree/master/osmnet/tests), and submit a PR
- respond to the code review
## Updating the documentation:

- See instructions in `docs/README.md`


## Preparing a release:

- Make a new branch for release prep

- Update the version number and changelog
- Update the version number and changelog:
- `CHANGELOG.md`
- `setup.py`
- `osmnet/__init__.py`
- `docs/source/index.rst`
- `docs/source/conf.py`

- Make sure all the tests are passing, and check if updates are needed to `README.md` or to the documentation

- Open a pull request to the master branch to finalize it

- After merging, tag the release on GitHub and follow the distribution procedures below
- Open a pull request to the `dev` branch to finalize it and wait for a PR review and approval

- After the PR has been approved, it can be merged to `dev`. Then a release PR can be created from `dev` to merge into `master`. Once merged, tag the release on GitHub and follow the distribution procedures below:

## Distributing a release on PyPI (for pip installation):

- Register an account at https://pypi.org, ask one of the current maintainers to add you to the project, and `pip install twine`

- Check out the copy of the code you'd like to release

- Run `python setup.py sdist bdist_wheel --universal`
- Run `python setup.py sdist bdist_wheel` (WITHOUT the `--universal` flag, since OSMnet no longer supports Python 2)

- This should create a `dist` directory containing two package files -- delete any old ones before the next step
- This should create a `dist` directory containing a gzip package file -- delete any old ones before the next step

- Run `twine upload dist/*` -- this will prompt you for your pypi.org credentials

Expand All @@ -49,8 +70,12 @@

## Distributing a release on Conda Forge (for conda installation):

- The [conda-forge/osmnet-feedstock](https://github.com/conda-forge/osmnet-feedstock) repository controls the Conda Forge release
- The [conda-forge/osmnet-feedstock](https://github.com/conda-forge/osmnet-feedstock) repository controls the Conda Forge release, including which GitHub users have maintainer status for the repo

- Conda Forge bots usually detect new releases on PyPI and set in motion the appropriate feedstock updates, which a current maintainer will need to approve and merge

- Maintainers can add on additional changes before merging the PR, for example to update the requirements or edit the list of maintainers

- You can also fork the feedstock and open a PR manually. It seems like this must be done from a personal account (not a group account like UDST) so that the bots can be granted permission for automated cleanup

- Check https://anaconda.org/conda-forge/osmnet for the new version (may take a few minutes for it to appear)
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007

Copyright (C) 2020 UrbanSim Inc.
Copyright (C) 2022 UrbanSim Inc.

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Overview

OSMnet offers tools to download street network data from OpenStreetMap
and extract a graph network comprised of nodes and edges to be used in
`Pandana`_ street network accessibility calculations.
`Pandana`_ street network accessibility calculations and or `UrbanAccess`_
to connect GTFS transit networks to road networks.

Let us know what you are working on or if you think you have a great use case
by tweeting us at ``@urbansim`` or post on the UrbanSim `forum`_.
by tweeting us at ``@urbansim``.

Library Status
--------------
Expand Down Expand Up @@ -84,7 +85,6 @@ Related UDST libraries
.. _OSMnet repo: https://github.com/udst/osmnet
.. _here: https://udst.github.io/osmnet/index.html
.. _UrbanAccess: https://github.com/UDST/urbanaccess
.. _forum: http://discussion.urbansim.com/

.. |Build Status| image:: https://travis-ci.org/UDST/osmnet.svg?branch=master
:target: https://travis-ci.org/UDST/osmnet
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ build: false

environment:
matrix:
- PYTHON: 3.6
- PYTHON: 3.8

init:
- "ECHO %PYTHON%"
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
source_suffix = '.rst'
master_doc = 'index'
project = u'OSMnet'
copyright = u'2020, UrbanSim Inc.'
copyright = u'2023, UrbanSim Inc.'
author = u'UrbanSim Inc.'
version = u'0.1.6'
release = u'0.1.6'
version = u'0.1.7'
release = u'0.1.7'
language = None

nitpicky = True
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OSMnet

Tools for the extraction of `OpenStreetMap`_ (OSM) street network data. Intended to be used in tandem with `Pandana`_ and `UrbanAccess`_ libraries to extract street network nodes and edges.

v0.1.6, released July 13, 2020.
v0.1.7, released August 7, 2023.

Contents
--------
Expand Down
4 changes: 1 addition & 3 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Introduction
OSMnet provides tools for the extraction of `OpenStreetMap`_ (OSM) street network data. OSMnet is intended to be used in tandem with `Pandana`_ and `UrbanAccess`_ libraries to extract street network nodes and edges.

Let us know what you are working on or if you think you have a great use case
by tweeting us at ``@urbansim`` or post on the UrbanSim `forum`_.
by tweeting us at ``@urbansim``.

Reporting bugs
~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -39,5 +39,3 @@ Related UDST libraries
.. _Pandana: https://github.com/UDST/pandana

.. _UrbanAccess: https://github.com/UDST/urbanaccess

.. _forum: http://discussion.urbansim.com/
2 changes: 1 addition & 1 deletion osmnet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .load import *

__version__ = "0.1.6"
__version__ = "0.1.7"

version = __version__
33 changes: 16 additions & 17 deletions osmnet/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def osm_net_download(lat_min=None, lng_min=None, lat_max=None, lng_max=None,
polygon = Polygon([(lng_max, lat_min), (lng_min, lat_min),
(lng_min, lat_max), (lng_max, lat_max)])
geometry_proj, crs_proj = project_geometry(polygon,
crs={'init': 'epsg:4326'})
crs="EPSG:4326")

# subdivide the bbox area poly if it exceeds the max area size
# (in meters), then project back to WGS84
Expand All @@ -144,11 +144,11 @@ def osm_net_download(lat_min=None, lng_min=None, lat_max=None, lng_max=None,
geometry, crs = project_geometry(geometry_proj_consolidated_subdivided,
crs=crs_proj, to_latlong=True)
log('Requesting network data within bounding box from Overpass API '
'in {:,} request(s)'.format(len(geometry)))
'in {:,} request(s)'.format(len(geometry.geoms)))
start_time = time.time()

# loop through each polygon in the geometry
for poly in geometry:
for poly in geometry.geoms:
# represent bbox as lng_max, lat_min, lng_min, lat_max and round
# lat-longs to 8 decimal places to create
# consistent URL strings
Expand All @@ -168,7 +168,7 @@ def osm_net_download(lat_min=None, lng_min=None, lat_max=None, lng_max=None,

log('Downloaded OSM network data within bounding box from Overpass '
'API in {:,} request(s) and'
' {:,.2f} seconds'.format(len(geometry), time.time()-start_time))
' {:,.2f} seconds'.format(len(geometry.geoms), time.time()-start_time))

# stitch together individual json results
for json in response_jsons_list:
Expand Down Expand Up @@ -234,7 +234,7 @@ def overpass_request(data, pause_duration=None, timeout=180,

# get the response size and the domain, log result
size_kb = len(response.content) / 1000.
domain = re.findall(r'//(?s)(.*?)/', url)[0]
domain = re.findall(r'(?s)//(.*?)/', url)[0]
log('Downloaded {:,.1f}KB from {} in {:,.2f} seconds'
.format(size_kb, domain, time.time()-start_time))

Expand Down Expand Up @@ -428,10 +428,11 @@ def project_geometry(geometry, crs, to_latlong=False):

Parameters
----------
geometry : shapely Polygon or MultiPolygon
geometry : shapely.geometry.Polygon or shapely.geometry.MultiPolygon
the geometry to project
crs : int
crs : string or pyproj.CRS
the starting coordinate reference system of the passed-in geometry
such as "EPSG:4326"
to_latlong : bool, optional
if True, project from crs to WGS84, if False, project
from crs to local UTM zone
Expand All @@ -441,11 +442,7 @@ def project_geometry(geometry, crs, to_latlong=False):
geometry_proj, crs : tuple (projected Shapely geometry, crs of the
projected geometry)
"""
gdf = gpd.GeoDataFrame()
gdf.crs = crs
gdf.name = 'geometry to project'
gdf['geometry'] = None
gdf.loc[0, 'geometry'] = geometry
gdf = gpd.GeoDataFrame(geometry=[geometry], crs=crs)
gdf_proj = project_gdf(gdf, to_latlong=to_latlong)
geometry_proj = gdf_proj['geometry'].iloc[0]
return geometry_proj, gdf_proj.crs
Expand All @@ -465,7 +462,7 @@ def project_gdf(gdf, to_crs=None, to_latlong=False):
----------
gdf : geopandas.GeoDataFrame
the GeoDataFrame to be projected
to_crs : dict or string or pyproj.CRS
to_crs : string or pyproj.CRS
if None, project to UTM zone in which gdf's centroid lies, otherwise
project to this CRS
to_latlong : bool
Expand All @@ -477,7 +474,8 @@ def project_gdf(gdf, to_crs=None, to_latlong=False):
the projected GeoDataFrame
"""
if gdf.crs is None or len(gdf) < 1:
raise ValueError("GeoDataFrame must have a valid CRS and cannot be empty")
raise ValueError(
"GeoDataFrame must have a valid CRS and cannot be empty")

# if to_latlong is True, project the gdf to latlong
if to_latlong:
Expand All @@ -490,15 +488,16 @@ def project_gdf(gdf, to_crs=None, to_latlong=False):
# otherwise, automatically project the gdf to UTM
else:
if gdf.crs.is_projected:
raise ValueError("Geometry must be unprojected to calculate UTM zone")
raise ValueError(
"Geometry must be unprojected to calculate UTM zone")

# calculate longitude of centroid of union of all geometries in gdf
avg_lng = gdf["geometry"].unary_union.centroid.x

# calculate UTM zone from avg longitude to define CRS to project to
utm_zone = int(math.floor((avg_lng + 180) / 6.0) + 1)
utm_crs = ('+proj=utm +zone={} +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
.format(utm_zone))
utm_crs = ('+proj=utm +zone={} +ellps=WGS84 '
'+datum=WGS84 +units=m +no_defs'.format(utm_zone))

# project the GeoDataFrame to the UTM CRS
gdf_proj = gdf.to_crs(utm_crs)
Expand Down
Loading