koopjs / koop-provider-ckan

CKAN provider for Koop (experimental).
Other
4 stars 5 forks source link

Coordinates are not parsed correctly #2

Open schlomm opened 9 years ago

schlomm commented 9 years ago

Hey Chris, It's me again :P I'm trying to solve an issue for the past two days without success, so I have decided to open an issue here. The problem: Existing coordinates in a .csv file of a ckan-site are not processed correctly. Although rows for the coordinates exist (of course with row names, which are defined by the whitelist), the coordinates are not parsed to the json geometry property, but only as additional attributes for the overall properties.

You can check a "working" example by registering the following CKAN-Portal: curl --data "host=http://www.opendata-hro.de&id=rostock" localhost:1337/ckan And request a dataset viakoop-server/ckan/rostock/denkmale Raw-data can be reviewed here. Please note: If you want to list all available datasets you need to add the parameter ?-d to the ckan.ckan_list_path. Otherwise the request would fail.

I have already looked for a fix, but in fact I have not found the error. From my point of view, there isn't a big difference between other examples, which you've mentioned in the ckan Readme.md except of a higher precision regarding decimal numbers.

Maybe you have an idea how to fix that? Greetings!

jgravois commented 9 years ago

sorry for the delayed reply.

this is happening because your latitude field has an index position of zero and hence returns false when we check to ensure that the variables have been set. see this SE thread for more info.

lat = 0;
lon = 1;
( lat && lon ) //returns false

the problem is resolved by substitituing something like this:

if ( typeof(lat) != 'undefined' && typeof(lon) != 'undefined' ){

i'll wait to submit a PR though, because i'm not sure if this is the cheapest/best solution.

edit: i see that @chelm was already forcing string conversion by concatenating each value with '', so i really don't understand why the original check is problematic.