我正在尝试使用nodejs模块:https://github.com/Esri/terraformer-arcgis-parser

以下是直接来自示例文档的代码:

var ArcGIS = require('terraformer-arcgis-parser');

// parse ArcGIS JSON, convert it to a Terraformer.Primitive (GeoJSON)
var primitive = ArcGIS.parse({
    x:"-122.6764",
    y:"45.5165",
    spatialReference: {
      wkid: 4326
    }
  });

// take a Terraformer.Primitive or GeoJSON and convert it back to ArcGIS JSON
var point = ArcGIS.convert({
  "type": "Point",
  "coordinates": [45.5165, -122.6764]
});


我得到:

throw new Error("Unknown type: " + geojson.type);

Error: Unknown type: undefined


有什么问题看来这甚至应该不是问题...

最佳答案

arcgis解析器期望x和y坐标的类型为“数字”,而不是示例中的字符串。

只需将您的arcgis json x和y更改为float即可,如下所示:

var primitive = ArcGIS.parse({
    x:-122.6764,
    y:45.5165,
    spatialReference: {
        wkid: 4326
    }
});

关于node.js - terraformer-arcgis-parser nodejs模块错误,带有示例代码?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26006270/

10-09 18:15