Giter Club home page Giter Club logo

Comments (6)

amrutab4 avatar amrutab4 commented on June 24, 2024 1

@jgravois Thank you so much for your valuable suggestions. I will surely try what your mentioned! :)

from arcgis-to-geojson-utils.

jgravois avatar jgravois commented on June 24, 2024

but when you run Features to JSON, your input isn't GeoJSON, correct?

from arcgis-to-geojson-utils.

amrutab4 avatar amrutab4 commented on June 24, 2024

@jgravois Obviously my input is not geojson, but the "esri JSON" which gets generated has "features" inside of it so that it can be easily used in arcGIS JS api to create and access featureset, graphic etc objects and loop through it! But when I am using JSON which is getting generated by 'arcgis-to-geojson-utils' I am not able to consume it in ArcGIS JS api :( I am just wondering, what is the meaning of "ESRI JSON" then and what is the difference between normal JSON and ESRI JSON? Also, Geometry type will always come as "esripolygon"/"esriPoint" in any of the esri generated json. But this is not the case here as well.

from arcgis-to-geojson-utils.

jgravois avatar jgravois commented on June 24, 2024

what is the meaning of "ESRI JSON" then.

The Esri ecosystem includes an incredibly extensive open REST Specification that articulates what all sorts of different Esri JSON looks like. This JavaScript library is concerned specifically with converting back and forth between individual ArcGIS Feature Objects / ArcGIS Geometry Objects and the corresponding GeoJSON Geometry and Feature objects.

When you run Features to JSON in ArcGIS Desktop using ArcGIS input data, ArcGIS FeatureSet output is possible because metadata that describes field aliases, schema types and which field is used for display are available for the tool to introspect.

This just isn't the case with GeoJSON. that is why we don't advertise ArcGIS FeatureSet output as being available from this library.

Geometry type will always come as "esripolygon"/"esriPoint" in any of the esri generated json. But this is not the case here as well.

I don't follow you here. can you elaborate?

from arcgis-to-geojson-utils.

amrutab4 avatar amrutab4 commented on June 24, 2024

@jgravois
Hey Hi,
Thank you so much for the prompt response! Yes I agree that ESRI includes vast REST specifications and you don't advertise featureset object either.

Correct me if I am wrong here but I assumed that whatever 'ArcGIS JSON' will get generated from this utility will get consumed in ArcMap, Pro, ArcMap 10.5.1, might be in 'JSON to Features' tool? or I can pass that to ArcGIS REST API calls or ArcGIS JS API call? Is my assumption correct or not?

About Geometry type, When you give any geojson as an input to the function "geojsonToArcGIS" in index.js, there is this case called "polygon" which fetches the rings because of it's geojso.type =
polygon' I think this polygon should be part of the response as "geometryType: "esriPolygon" as this is identifiable by ArcGIS. Let me know your thoughts about it?

Additionally, I have made few (not so good) changes in the function 'geojsonToArcGIS' to explain what should be the output. I am focusing on passing polygon geojson. Pleasse take a look at the below function for more idea:

 var ft = new Array();
 
 function geojsonToArcGIS (geojson, idAttribute) {
  idAttribute = idAttribute || 'OBJECTID';
  var spatialReference = { wkid: 4326 };
 // var geomType = "esriGeometry" + geojson.type;
  var result = {};
  var i;
 
  switch (geojson.type) {
    case 'Point':
      result.x = geojson.coordinates[0];
      result.y = geojson.coordinates[1];
      result.spatialReference = spatialReference;
      break;
    case 'MultiPoint':
      result.points = geojson.coordinates.slice(0);
      result.spatialReference = spatialReference;
      break;
    case 'LineString':
      result.paths = [geojson.coordinates.slice(0)];
      result.spatialReference = spatialReference;
      break;
    case 'MultiLineString':
      result.paths = geojson.coordinates.slice(0);
      result.spatialReference = spatialReference;
      break;
      case 'Polygon':
         
          ft.rings = orientRings(geojson.coordinates.slice(0));
         // result.features.geometry.rings = ft.rings;
          // result.spatialReference = spatialReference;
         // result.geometryType = geomType;
         
      break;
    case 'MultiPolygon':
      result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));
      result.spatialReference = spatialReference;
      break;
      case 'Feature':
          if (geojson.geometry) {
              result.spatialReference = spatialReference;
              result.geometryType = "esriGeometry" + geojson.geometry.type;
             
              ft.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);
              ft["geometry"].rings = ft["rings"];
              delete ft.rings;
             ft.attributes = (geojson.properties) ? shallowClone(geojson.properties) : {};
             
             
          }
         
          if (geojson.id) {
              ft.attributes[idAttribute] = geojson.id;
          }
          result["features"] = ft;
          result["features"].push(ft);
          break;
    case 'FeatureCollection':
        result = [];
        for (i = 0; i < geojson.features.length; i++) {
           // result.push(geojsonToArcGIS(geojson.features[i], idAttribute));
            result = geojsonToArcGIS(geojson.features[i], idAttribute);
        }
      break;
    case 'GeometryCollection':
      result = [];
      for (i = 0; i < geojson.geometries.length; i++) {
          result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute));
      }
      break;
  }
  
  return result;
} 

I have one more query, I want to convert geojson to arcgis json and I should be able to consume that json in ArcMap 10.5.1 as well as in ArcGIS JS api to create features and graphics so I was looking forward to using this 'arcgis-to-geojson-utils' and as it is licensed under ESRI 2018 so wondering If I am at the right place or if you can suggest me any other library?

Looking forward to your response.

Thanks!

from arcgis-to-geojson-utils.

jgravois avatar jgravois commented on June 24, 2024

'ArcGIS JSON' generated from this utility will get consumed in ArcMap, Pro, ArcMap 10.5.1, might be in 'JSON to Features' tool?

I'm not really sure what the most popular locations of consumption for output from this library are. that said, JSON to Features expects ArcGIS FeatureSet input and this library does not output that.

I think this polygon should be part of the response as geometryType: "esriGeometryPolygon". Let me know your thoughts about it?

I see what you're getting at now, but your current approach appends the type to each individual feature within the collection, which isn't valid. and it looks like your previous attempt was to check the type of the FeatureCollection itself, which it appears you already realized won't work either.

you could certainly refactor your own forked code to check the type of individual features and use the information to set the type for the entire collection, but i don't plan on incorporating a change like that in this library for the simple reason that it is valid for a GeoJSON FeatureCollection to include mixed geometry types.

wondering if I am at the right place or if you can suggest me any other library?

you are in the right place, but instead of what you've been doing, you should try to build up a FeatureSet of your own around the output of the lib if that's what you need.

let featureSet = {
  "geometryType": "esriGeometryPolygon",
  "features": null
  // etc. 
}

featureSet.features = geojsonToArcGIS(featureCollection);

from arcgis-to-geojson-utils.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.