Open tomwayson opened 1 year ago
greetings old friend. 👋
a PR (to DefinitelyTyped) would most certainly be welcome.
greetings indeed.
I did start on that, but the above change didn't solve the problem in my environment, likely due to mismatches between the "arcgis-rest-api" types and the corresponding types from @arcgis/core and I just ended up sprinkling as any
through my code.
This made me wonder if the types for this library should be using the actual types from @arcgis/core, but that feels like a bigger issue.
i don't have any firm opinions about better Typescript support. this library is pretty mature/stable at this point so i'm not opposed to (someone else) tackling a full-blown revamp. i wouldn't expect it to be yeoman's work.
i'd also be fine with moving the typings here if it'd make maintenance easier. ❤️
Except for type errors,The code for this function geojsonToArcGIS needs to be optimized ` var geojsonToArcGIS = function geojsonToArcGIS(geojson, idAttribute) { idAttribute = idAttribute || 'OBJECTID'; var spatialReference = { wkid: 4326 }; var result = {}; var i;
switch (geojson.type) { case 'Point': result.x = geojson.coordinates[0]; result.y = geojson.coordinates[1];
if (geojson.coordinates[2] != null) {
result.z = geojson.coordinates[2];
}
result.spatialReference = spatialReference;
break;
case 'MultiPoint':
result.points = geojson.coordinates.slice(0);
if (geojson.coordinates[0][2] != null) {
result.hasZ = true;
}
result.spatialReference = spatialReference;
break;
case 'LineString':
result.paths = [geojson.coordinates.slice(0)];
if (geojson.coordinates[0][2] != null) {
result.hasZ = true;
}
result.spatialReference = spatialReference;
break;
case 'MultiLineString':
result.paths = geojson.coordinates.slice(0);
if (geojson.coordinates[0][0][2] != null) {
result.hasZ = true;
}
result.spatialReference = spatialReference;
break;
case 'Polygon':
result.rings = orientRings(geojson.coordinates.slice(0));
if (geojson.coordinates[0][0][2] != null) {
result.hasZ = true;
}
result.spatialReference = spatialReference;
break;
case 'MultiPolygon':
result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));
if (geojson.coordinates[0][0][0][2] != null) {
result.hasZ = true;
}
result.spatialReference = spatialReference;
break;
case 'Feature':
if (geojson.geometry) {
result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);
}
result.attributes = geojson.properties ? shallowClone(geojson.properties) : {};
if (geojson.id) {
result.attributes[idAttribute] = geojson.id;
}
break;
case 'FeatureCollection':
result = [];
for (i = 0; i < geojson.features.length; i++) {
result.push(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; };
`
the result should be an array or an object , so 'var result = {}' this code is error ,
Seems like this line
Should be:
Based on the description: