Skip to content

Commit

Permalink
Merge pull request #49 from openaddresses/fix-geojson-properties
Browse files Browse the repository at this point in the history
Fix property generation in geojsonld
  • Loading branch information
iandees authored Sep 2, 2023
2 parents 101f758 + f60898b commit de60af6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 0 additions & 2 deletions openaddr/process_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ def render_geojsonld(csv_filename, temp_dir):

for k, v in row.items():
feat["properties"][k.lower()] = v
else:
feat["properties"] = None

geojsonld_file.write(json.dumps(feat, sort_keys=True, separators=(',', ':')))
geojsonld_file.write('\n')
Expand Down
11 changes: 10 additions & 1 deletion openaddr/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def test_single_iceland(self):
source = join(self.src_dir, 'iceland.json')

with mock.patch('openaddr.util.request_ftp_file', new=self.response_content_ftp):
state_path = process_one.process(source, self.testdir, "addresses", "default", False, False, False, False)
state_path = process_one.process(source, self.testdir, "addresses", "default", True, False, False, False)

with open(state_path) as file:
state = dict(zip(*json.load(file)))
Expand All @@ -848,6 +848,7 @@ def test_single_iceland(self):
self.assertIsNone(state['slippymap'])
self.assertIsNotNone(state['processed'])
self.assertIsNotNone(state['cache'])
self.assertIsNotNone(state['geojsonld'])

with open(join(dirname(state_path), state['processed']), encoding='utf8') as file:
rows = list(csv.DictReader(file))
Expand All @@ -857,6 +858,14 @@ def test_single_iceland(self):
self.assertEqual(rows[2]['GEOM'], 'POINT (-21.7684622 64.110974)')
self.assertEqual(rows[3]['GEOM'], 'POINT (-21.7665982 64.1100444)')

with open(join(dirname(state_path), state['geojsonld']), encoding='utf8') as file:
features = [json.loads(line) for line in file]

self.assertEqual(len(features), 15)
self.assertEqual(features[0]['properties']['street'], u'2.Gata v/Rauðavatn')
self.assertEqual(features[2]['geometry']['coordinates'], [-21.7684622, 64.110974])
self.assertEqual(features[3]['geometry']['coordinates'], [-21.7665982, 64.1100444])

def test_single_fr_paris(self):
''' Test complete process_one.process on data that uses conform csvsplit (issue #124)
'''
Expand Down

0 comments on commit de60af6

Please sign in to comment.