Skip to content

Commit

Permalink
Merge pull request #15 from openaddresses/order
Browse files Browse the repository at this point in the history
Coordinate Order
  • Loading branch information
ingalls authored Jun 16, 2021
2 parents 21f2630 + 8110d07 commit 8bb6ecf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apk add nodejs yarn git python3 python3-dev py3-pip \
py3-cairo file

# Download and install Tippecanoe
RUN git clone -b 1.35.0 https://github.com/mapbox/tippecanoe.git /tmp/tippecanoe && \
RUN git clone -b 1.36.0 https://github.com/mapbox/tippecanoe.git /tmp/tippecanoe && \
cd /tmp/tippecanoe && \
make && \
PREFIX=/usr/local make install && \
Expand Down
6 changes: 6 additions & 0 deletions openaddr/conform.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,15 @@ def _transform_to_4326(srs):
if srs not in _transform_cache:
epsg_id = int(srs[5:]) if srs.startswith("EPSG:") else int(srs)
# Manufacture a transform object if it's not in the cache

in_spatial_ref = osr.SpatialReference()
in_spatial_ref.ImportFromEPSG(epsg_id)
out_spatial_ref = osr.SpatialReference()
out_spatial_ref.ImportFromEPSG(4326)

# GDAL 3 changes axis order: https://github.com/OSGeo/gdal/issues/1546
out_spatial_ref.SetAxisMappingStrategy(osgeo.osr.OAMS_TRADITIONAL_GIS_ORDER)

_transform_cache[srs] = osr.CoordinateTransformation(in_spatial_ref, out_spatial_ref)
return _transform_cache[srs]

Expand Down Expand Up @@ -937,6 +942,7 @@ def row_extract_and_reproject(source_config, source_row):
out_row[GEOM_FIELDNAME] = None
return out_row


# Reproject the coordinates if necessary
if "srs" in data_source["conform"]:
try:
Expand Down
6 changes: 3 additions & 3 deletions openaddr/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,9 @@ def test_single_jp_fukushima2(self):
self.assertEqual(rows[1]['STREET'], u'田沢字躑躅ケ森')
self.assertEqual(rows[2]['NUMBER'], u'22-9')
self.assertEqual(rows[2]['STREET'], u'小田字正夫田')
self.assertEqual(rows[0]['GEOM'], 'POINT (140.480007 37.706391)')
self.assertEqual(rows[1]['GEOM'], 'POINT (140.486267 37.707664)')
self.assertEqual(rows[2]['GEOM'], 'POINT (140.41875 37.710239)')
self.assertEqual(rows[0]['GEOM'], 'POINT (37.706391 140.480007)')
self.assertEqual(rows[1]['GEOM'], 'POINT (37.707664 140.486267)')
self.assertEqual(rows[2]['GEOM'], 'POINT (37.710239 140.41875)')

def test_single_utah(self):
''' Test complete process_one.process on data that uses file selection with mixed case (issue #104)
Expand Down
6 changes: 3 additions & 3 deletions openaddr/tests/conform.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def test_row_extract_and_reproject(self):
}), "addresses", "default")
r = row_extract_and_reproject(d, {GEOM_FIELDNAME: "POINT (7655634.924 668868.414)"})

self.assertEqual('POINT (45.4815543938511 -122.630842186651)', r[GEOM_FIELDNAME])
self.assertEqual('POINT (-122.630842186651 45.4815543938511)', r[GEOM_FIELDNAME])

d = SourceConfig(dict({
"schema": 2,
Expand Down Expand Up @@ -1840,7 +1840,7 @@ def test_lake_man_3740(self):
self.assertEqual(0, rc)
with open(dest_path) as fp:
rows = list(csv.DictReader(fp))
self.assertEqual(rows[0]['GEOM'], 'POINT (37.8026123 -122.2592495)')
self.assertEqual(rows[0]['GEOM'], 'POINT (-122.2592495 37.8026123)')
self.assertEqual(rows[0]['NUMBER'], '5')
self.assertEqual(rows[0]['STREET'], u'PZ ESPA\u00d1A')

Expand Down Expand Up @@ -2212,7 +2212,7 @@ def test_srs(self):
u'3203,SE WOODSTOCK BLVD,7655634.924,668868.414'.encode('ascii'))
r = self._convert(c, d)
self.assertEqual(r[0], u'n,s,{GEOM_FIELDNAME}'.format(**globals()))
self.assertEqual(r[1], u'3203,SE WOODSTOCK BLVD,POINT (45.4815543938511 -122.630842186651)')
self.assertEqual(r[1], u'3203,SE WOODSTOCK BLVD,POINT (-122.630842186651 45.4815543938511)')

def test_too_many_columns(self):
"Check that we don't barf on input with too many columns in some rows"
Expand Down
4 changes: 2 additions & 2 deletions openaddr/tests/conforms/jp-nara.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"conform": {
"format": "csv",
"lat": "\u7def\u5ea6",
"lon": "\u7def\u5ea6",
"srs": "EPSG:4612",
"number": "auto_number",
"number": {
Expand All @@ -27,7 +27,7 @@
"separator": "-"
},
"street": "\u5927\u5b57\u30fb\u753a\u4e01\u76ee\u540d",
"lon": "\u7d4c\u5ea6",
"lat": "\u7d4c\u5ea6",
"encoding": "SHIFT_JISX0213"
},
"license": "http://nlftp.mlit.go.jp/ksj/other/yakkan.html"
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@

# Used in openaddr.parcels
'Shapely == 1.7.1',
'Fiona == 1.8.17',

# Used in dotmaps preview to support S3-backed SQLite mbtiles
# https://rogerbinns.github.io/apsw/
Expand All @@ -77,6 +76,5 @@
'mapbox-vector-tile==1.2.0',
'future==0.16.0',
'protobuf==3.5.1',
'pyclipper==1.1.0'
]
)

0 comments on commit 8bb6ecf

Please sign in to comment.