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

esriJSON feature arrays not captured by parse() in arcgis.js #104

Closed
abenrob opened this issue Jun 22, 2013 · 8 comments
Closed

esriJSON feature arrays not captured by parse() in arcgis.js #104

abenrob opened this issue Jun 22, 2013 · 8 comments
Labels

Comments

@abenrob
Copy link

@abenrob abenrob commented Jun 22, 2013

Is this intentional?
When I point to an AGS JSON rest endpoint and try to parse to geoJSON, the object matches no cases and the geoJSON object remains empty.
If I limit to one feature (e.g. arcgis.features[0]) the conversion succeeds.

@patrickarlt
Copy link
Contributor

@patrickarlt patrickarlt commented Jun 24, 2013

@abenrob There is an explict reason we don't support this but do support converting single features. When you parse a feature into GeoJSON like

var geojson = Terraformer.ArcGIS.parse(arcgis.features[0]);

Does not produce valid GeoJSON because geojson.id is undefined. Valid GeoJSON Features must have a id property. Since converting an array of ArcGIS features to an array of GeoJSON Features would result in alot of invalud GeoJSON you should do this in a loop like this...

var FeatureCollection = {
  type: "FeatureCollection",
  features: []
}

for (var i = 0; i < arcgis.features.length; i++) {
  var feature = Terraformer.ArcGIS.parse(arcgis.features[i]);
  feature.id = i;
  FeatureCollection.features.push(feature)
};

If we allow passing an array we also open our selves up to bugs where mixed arrays of geometries and features are passed (which cant exist in GeoJSON) and would require us to sort them out into FeatureCollections or GeometryCollections.

@abenrob
Copy link
Author

@abenrob abenrob commented Jun 24, 2013

Thanks for the clarification.

@patrickarlt
Copy link
Contributor

@patrickarlt patrickarlt commented Jun 24, 2013

@abenrob fleshed out the explanation a little hit "Comment" to soon.

@jhobz
Copy link

@jhobz jhobz commented Jul 11, 2013

I believe you have a typo in your explanation. The following line:

FeatureCollection.features.push(geojson)

should probably read

FeatureCollection.features.push(feature)

right?

@patrickarlt
Copy link
Contributor

@patrickarlt patrickarlt commented Jul 16, 2013

@jeffreyhobson Thanks, corrected it.

@jgravois
Copy link
Collaborator

@jgravois jgravois commented Mar 29, 2018

hello from 2018!

in @esri/arcgis-to-geojson-utils we ultimately landed support for converting arrays of Esri JSON features into a GeoJSON FeatureCollection and auto-incrementing ids.

its also worth noting:

  • RFC 7946 the id requirement was downgraded from a MUST to a SHOULD
  • the Geoservices spec doesn't emit arrays of features with dissimilar geometries.
@hoogw
Copy link

@hoogw hoogw commented Apr 4, 2018

@jgravois

can you show me example, how to do it?


in @esri/arcgis-to-geojson-utils we ultimately landed support for converting arrays of Esri JSON features into a GeoJSON FeatureCollection and auto-incrementing ids.

@jgravois
Copy link
Collaborator

@jgravois jgravois commented Apr 4, 2018

@hoogw no need to respost the same question in three different places. i've answered you in Esri/arcgis-to-geojson-utils#30 (comment)

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

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.