OpenUpSA/wazimap

Error when trying to locate using co-ordinates

divyamani1 opened this issue · 3 comments

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)

@ebsuku What do you think?

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?

@ebsuku Sure.