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

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

Comments

Projects
None yet
5 participants
@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

This comment has been minimized.

Show comment
Hide comment
@patrickarlt

patrickarlt Jun 24, 2013

Member

@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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@abenrob

abenrob Jun 24, 2013

Thanks for the clarification.

abenrob commented Jun 24, 2013

Thanks for the clarification.

@patrickarlt

This comment has been minimized.

Show comment
Hide comment
@patrickarlt

patrickarlt Jun 24, 2013

Member

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

Member

patrickarlt commented Jun 24, 2013

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

@jhobz

This comment has been minimized.

Show comment
Hide comment
@jhobz

jhobz 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?

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

This comment has been minimized.

Show comment
Hide comment
@patrickarlt

patrickarlt Jul 16, 2013

Member

@jeffreyhobson Thanks, corrected it.

Member

patrickarlt commented Jul 16, 2013

@jeffreyhobson Thanks, corrected it.

@jgravois jgravois referenced this issue in Esri/terraformer-arcgis-parser Mar 16, 2016

Closed

add FeatureSet to FeatureCollection #31

@jgravois jgravois referenced this issue in Esri/terraformer-arcgis-parser Aug 3, 2017

Closed

Parse from Arcgis Feature Collection to Geojson #48

@jgravois jgravois referenced this issue in Esri/arcgis-to-geojson-utils Mar 19, 2018

Merged

convert ArcGIS features array to GeoJSON FeatureCollection #28

@jgravois

This comment has been minimized.

Show comment
Hide comment
@jgravois

jgravois Mar 29, 2018

Member

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.
Member

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

This comment has been minimized.

Show comment
Hide comment
@hoogw

hoogw 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.

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 jgravois referenced this issue in Esri/arcgis-to-geojson-utils Apr 4, 2018

Closed

How to convert arcgis featureSet to geojson? #30

@jgravois

This comment has been minimized.

Show comment
Hide comment
@jgravois

jgravois Apr 4, 2018

Member

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

Member

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