OpenUpSA / wazimap

Wazimap is a Django application for exploring census data.
http://wazimap.readthedocs.org/en/latest/
Other
30 stars 31 forks source link

Error when trying to locate using co-ordinates #158

Closed divyamani1 closed 4 years ago

divyamani1 commented 4 years ago

When trying to access endpoint /locate/ the following error occurs:

KeyError at  locate

I'm working on the Nepalmap instance of Wazimap and trying to upgrade it to Python 3. I skimmed through the documentation but couldn't find much help (maybe I missed something).

The function get_locations_from_coords (line 286) in wazimap/geo.py expects geometry features in following format:

{'properties': values, 'shape': values}

while currently it receives:

{'NP': {'properties': values, 'shape': values}}

and the above error occurs.

I edited the code in geo.py (line 286-291) as follows and it works fine.

       for feature in features.values():
           code_value = list(feature.keys())[0]
           if feature['code_value']['shape'] and feature['code_value']['shape'].contains(p):
               geo = self.get_geography(feature['code_value']['properties']['code'],
                                        feature['code_value']['properties']['level'],
                                        version)
divyamani1 commented 4 years ago

@ebsuku What do you think?

knightebsuku commented 4 years ago

Hi @divyamani1, I've not have time to look into this as of yet. I'll schedule some time early next week. Could you create a pull request with your proposed changes?

divyamani1 commented 4 years ago

@ebsuku Sure.