koopjs / FeatureServer

An open source Geoservices Implementation (deprecated)
https://geoservices.github.io
Other
101 stars 32 forks source link

Unable to set `hasZ` or `hasM` #228

Closed LeviRemi closed 2 years ago

LeviRemi commented 2 years ago

I am sending 4-dimensional coordinates to Koop as an esriGeometryPoint, but only the x and y coordinates are returning from a feature layer query. I suspect this is due to the hasZ and hasM properties being false, but I cannot find a way to manually set them true.

I tried passing hasZ: true and hasM: true in the geojson's metadata for koop's getData() callback function, but have had no success. Could anyone tell me how this is done, or if this is even possible? Thanks in advanced!

GeoJSON plugged into getData callback:

{
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: {
        FacilityName: 'HBG-05',
        esriOid: 2
      },
      geometry: { coordinates: [ -78.9153, 36.18083, 0, 100 ], type: 'Point' }
    }
  ],
  metadata: {
      idField: 'esriOid',
      name: 'Koop Test',
      maxRecordCount: 5000,
      fields: [
        { name: 'FacilityName', type: 'String', alias: 'Facility Name' }
      ],
      geometryType: 'esriGeometryPoint',
      hasZ: true,
      hasM: true
    }
}

GeoJSON response from Koop on FeatureLayer query:

{
    "objectIdFieldName": "esriOid",
    "uniqueIdField": {
        "name": "esriOid",
        "isSystemMaintained": true
    },
    "globalIdFieldName": "",
    "hasZ": false,
    "hasM": false,
    "spatialReference": {
        "wkid": 4326,
        "latestWkid": 4326
    },
    "fields": [
        {
            "name": "esriOid",
            "type": "esriFieldTypeOID",
            "alias": "Object ID",
            "sqlType": "sqlTypeInteger",
            "domain": null,
            "defaultValue": null
        },
        {
            "name": "FacilityName",
            "type": "esriFieldTypeString",
            "alias": "Facility Name",
            "sqlType": "sqlTypeOther",
            "domain": null,
            "defaultValue": null,
            "length": 128
        }
    ],
    "features": [
        {
            "attributes": {
                "FacilityName": "HBG-05",
                "esriOid": 2
            },
            "geometry": {
                "x": -78.9153,
                "y": 36.18083
            }
        },
    ],
    "exceededTransferLimit": false,
    "geometryType": "esriGeometryPoint"
}
rgwozdz commented 2 years ago

@LeviRemi - I track this down. It's deep down in the dependency chain; when you get down to it, this repo is use to convert geojson geometry to Esri geometry. See this code specifically:

    case 'Point':
      result.x = geojson.coordinates[0];
      result.y = geojson.coordinates[1];
      if (geojson.coordinates[2]) {
        result.z = geojson.coordinates[2];
      }
      result.spatialReference = spatialReference;
      break;

Note that m is not handled at all. z should get set, but their check, if (geojson.coordinates[2]), fails to work as needed when the value of the third coordinate is 0, as it is in your example. Really, the best thing to do would be get a PR fix in on that repo - to properly handle z coordinates, and to handle m coordinates as well

rgwozdz commented 2 years ago

@LeviRemi - note that the GeoJSON spec doesn't say anything about m-values; just x, y, z.

rgwozdz commented 2 years ago

Bug logged at https://github.com/terraformer-js/terraformer/issues/78.

LeviRemi commented 2 years ago

@rgwozdz Nice catch! I will take a look at the terraformer code today and see about submitting a PR.

As for M Values, that's a good point. Probably best to abandon expectation of built-in M support when the GeoJSON spec itself omits it. I have other ways of tracking the M value, so no worries there.

LeviRemi commented 2 years ago

PR open at terraformer-js/terraformer/pull/79

rgwozdz commented 2 years ago

I'll pull the updated dep into winnow, and note here when published.

rgwozdz commented 2 years ago

Released FeatureServer 3.5.1, which contains winnow 2.51, which contains terraformer 2.1.1, which has the fix.

LeviRemi commented 2 years ago

Excellent! Thank you for the quick update, @rgwozdz. I will close this for now since this update takes care of the Z-value issue and the missing m-value was determined to be a non-issue.