koopjs / FeatureServer

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

Fixes #34 - Filter by outfields before creating fields #36

Closed phpmaps closed 7 years ago

phpmaps commented 7 years ago

Feature Server is ignoring the outFields options when generating the fields response. Therefore, when clients get the response they think the Feature Set response contains these fields, when if fact it may not. So before creating fields, this fix filters metadata.fields so that it will only contain fields contained in the outFields options.

Give this request to Feature Server: (note date, OBJECTID in outfields)

FeatureServer/0/query?f=json&geometry={%22xmin%22:-13633964.480821775,%22ymin%22:4540069.018923454,%22xmax%22:-13618753.512193045,%22ymax%22:4553904.1210430525}&geometryType=esriGeometryEnvelope&inSR=102100&spatialRel=esriSpatialRelIntersects&outFields=date,OBJECTID&returnGeometry=true&maxAllowableOffset=38&outSR=102100&resultOffset=0&resultRecordCount=1000&where=1=1

Before this fix the fields response will look like this:

  "fields": [
    {
      "name": "date",
      "type": "esriFieldTypeDate",
      "alias": "date",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "description",
      "type": "esriFieldTypeString",
      "alias": "description",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "title",
      "type": "esriFieldTypeString",
      "alias": "title",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "OBJECTID",
      "type": "esriFieldTypeOID",
      "alias": "ID",
      "length": null,
      "editable": false,
      "nullable": false,
      "domain": null
    }
  ]

After this fix the fields the response will look like this, b/ outfields contains data :

  "fields": [
    {
      "name": "date",
      "type": "esriFieldTypeDate",
      "alias": "date",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "OBJECTID",
      "type": "esriFieldTypeOID",
      "alias": "ID",
      "length": null,
      "editable": false,
      "nullable": false,
      "domain": null
    }
  ]

If outFields does not contain data it will look like this (per commit 89d35e1).

  "fields": [
    {
      "name": "date",
      "type": "esriFieldTypeDate",
      "alias": "date",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "description",
      "type": "esriFieldTypeString",
      "alias": "description",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "title",
      "type": "esriFieldTypeString",
      "alias": "title",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "OBJECTID",
      "type": "esriFieldTypeOID",
      "alias": "ID",
      "length": null,
      "editable": false,
      "nullable": false,
      "domain": null
    }
  ]

See #34

phpmaps commented 7 years ago

@dmfenton ok here's an update per your clarification.