Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages for import URL and GeoJSON-Response #68

Open
tordans opened this issue Apr 14, 2018 · 1 comment
Open

Improve error messages for import URL and GeoJSON-Response #68

tordans opened this issue Apr 14, 2018 · 1 comment

Comments

@tordans
Copy link

tordans commented Apr 14, 2018

I am still trying to use the importer with #66.

ATM my problem is either the url format or the json format.
Unfortunatelly the importer is not very helpful in understanding and solving the error.

Ideally, the importer would talk to me about:

URL

  • Show a helpful error message if my URL is not valid. What is the problem? A missing param? Which one?
  • The importer should explain what import-URL-format is expected. And also, how the params are supposed to work.

JSON

  • Show a helpful error message if my JSON is invalid.
  • Reference a valid JSON and explain in which cases the importer just breaks and what cases can be filtered/ignored.

Testcases

Use properties or attributes?

The example URL from #66 (comment) @jgravois uses a properties. The http://geoservices.github.io/ example, that was referenced before, uses attributes .

Other usability improvements

Use case: I input an url -> see an error message -> change the URL -> see the same error message.
ATM it is not clear if the "second" error message is still the same as before or if the new URL still creates an (new) error.

@jgravois
Copy link
Collaborator

i agree. there is serious room for improvement in our current validation.

right now we:

  1. check to make sure the string that's entered is a url by making sure it includes http:// or https://. if not, we abort and display nothing.
  2. if its indeed a url, we check to see that it contains either /MapServer/ or /FeatureServer/ to make sure its a geoservice.

if (!new RegExp(/(map|feature)server/, 'i').test(this.value.toLowerCase())) {

we aren't validating the feature JSON at all. To make things a little more complicated, the query operation of modern geoservices is capable of emitting native GeoJSON (which include properties), while older geoservices only emit Esri flavored feature JSON (which include attributes).

side by side comparison: https://gist.github.com/jgravois/eab035258f8157d54618

currently we first fetch only metadata from the service to see whether it supports asking for native GeoJSON. If it doesn't we ask for Esri/Geoservice feature JSON and convert it into GeoJSON for iD client-side.

if (data.supportedQueryFormats && data.supportedQueryFormats.toLowerCase().indexOf('geojson') > -1) {

what you're trying to do is just store valid GeoJSON in a flat file on a server. a bit of refactoring of our code would necessary to short circuit the series of API calls we currently make once we are convinced the user has supplied a geoservice url.

right now we:
a) ask for metadata to determine whether or not support for f=geojson is present

http://maps.bouldercounty.org/arcgis/rest/services/PARCELS/BUILDINGS_STRUCTURE_FOOTPRINT/MapServer/0?f=json

b) first, fetch only a count of the features within the supplied bounding box

http://maps.bouldercounty.org/arcgis/rest/services/PARCELS/BUILDINGS_STRUCTURE_FOOTPRINT/MapServer/0/query?where=1=1&returnCountOnly=true&f=json&geometry={"xmin":-105.306621,"ymin":40.018343,"xmax":-105.269586,"ymax":40.028042,"spatialReference":{"wkid":4326}}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&inSR=4326

c) then fetch a count of the total number of features stored behind the entire service

http://maps.bouldercounty.org/arcgis/rest/services/PARCELS/BUILDINGS_STRUCTURE_FOOTPRINT/MapServer/0/query?where=1%3D1&returnCountOnly=true&f=json

d) lastly, fetch only the features within the supplied bounding box (using f=json only if support for f=geojson isn't present).

http://maps.bouldercounty.org/arcgis/rest/services/PARCELS/BUILDINGS_STRUCTURE_FOOTPRINT/MapServer/0/query?&outSR=4326&f=json&maxAllowableOffset=0.000005&outFields=StructureID&geometry={"xmin":-105.306621,"ymin":40.018343,"xmax":-105.269586,"ymax":40.028042,"spatialReference":{"wkid":4326}}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&inSR=4326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants