koopjs / FeatureServer

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

The layer descriptor does not set the "id" property #30

Closed jkerr5 closed 7 years ago

jkerr5 commented 7 years ago

When requesting the descriptor for a layer like

/<service>/FeatureServer/3

The id property in the response is always 0 but it should be the id of the layer requested. My provider implementation returns an id attribute in the metadata section but this is ignored as well.

jkerr5 commented 7 years ago

To clarify, the provider gets the layer id correctly in the request but the response always has id set to 0 regardless of what layer was requests.

For example, this URL

/GDeltGKG/FeatureServer/3

Produces this response from the provider

{
  "metadata": {
    "maxRecordCount": 100000,
    "id": 3,
    "name": "My Layer",
    "decription": "Demo",
    "geometryType": "Point",
    "objectIdField": "OBJECTID",
    "displayField": "url",
    "geometryPath": "\/geometry",
    "extent": {
      "xmin": -180,
      "ymin": -90,
      "xmax": 180,
      "ymax": 90,
      "spatialReference": {
        "wkid": 4326,
        "latestWkid": 4326
      }
    },
    "fields": [
      {
        "name": "OBJECTID",
        "type": "Integer"
      },
      {
        "name": "urlpubtimedate",
        "type": "Date"
      },
      {
        "name": "url",
        "type": "String"
      },
      {
        "name": "name",
        "type": "String"
      },
      {
        "name": "urltone",
        "type": "Double"
      },
      {
        "name": "sentiment",
        "type": "String"
      },
      {
        "name": "domain",
        "type": "String"
      },
      {
        "name": "urllangcode",
        "type": "String"
      },
      {
        "name": "geores",
        "type": "Integer"
      },
      {
        "name": "counter",
        "type": "Integer"
      },
      {
        "name": "attacktype",
        "type": "String"
      },
      {
        "name": "targettype",
        "type": "String"
      },
      {
        "name": "weapontype",
        "type": "String"
      },
      {
        "name": "eventid",
        "type": "String"
      },
      {
        "name": "eventsummary",
        "type": "String"
      }
    ]
  }
}

But koop produces this response

{
  "currentVersion": 10.31,
  "id": 0,
  "name": "My Layer",
  "type": "Feature Layer",
  "description": "This is a feature service powered by https:\/\/github.com\/featureserver\/featureserver",
  "geometryType": "esriGeometryPoint",
  "copyrightText": " ",
  "parentLayer": null,
  "subLayers": null,
  "minScale": 0,
  "maxScale": 0,
  "drawingInfo": {
    "renderer": {
      "type": "simple",
      "symbol": {
        "color": [
          45,
          172,
          128,
          161
        ],
        "outline": {
          "color": [
            190,
            190,
            190,
            105
          ],
          "width": 0.5,
          "type": "esriSLS",
          "style": "esriSLSSolid"
        },
        "size": 7.5,
        "type": "esriSMS",
        "style": "esriSMSCircle"
      }
    },
    "labelingInfo": null
  },
  "defaultVisibility": true,
  "extent": {
    "xmin": -180,
    "ymin": -90,
    "xmax": 180,
    "ymax": 90,
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    }
  },
  "hasAttachments": false,
  "htmlPopupType": "esriServerHTMLPopupTypeNone",
  "displayField": "url",
  "typeIdField": null,
  "fields": [
    {
      "name": "OBJECTID",
      "type": "esriFieldTypeInteger",
      "alias": "OBJECTID",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "urlpubtimedate",
      "type": "esriFieldTypeDate",
      "alias": "urlpubtimedate",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "url",
      "type": "esriFieldTypeString",
      "alias": "url",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "name",
      "type": "esriFieldTypeString",
      "alias": "name",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "urltone",
      "type": "esriFieldTypeDouble",
      "alias": "urltone",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "sentiment",
      "type": "esriFieldTypeString",
      "alias": "sentiment",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "domain",
      "type": "esriFieldTypeString",
      "alias": "domain",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "urllangcode",
      "type": "esriFieldTypeString",
      "alias": "urllangcode",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "geores",
      "type": "esriFieldTypeInteger",
      "alias": "geores",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "counter",
      "type": "esriFieldTypeInteger",
      "alias": "counter",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "attacktype",
      "type": "esriFieldTypeString",
      "alias": "attacktype",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "targettype",
      "type": "esriFieldTypeString",
      "alias": "targettype",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "weapontype",
      "type": "esriFieldTypeString",
      "alias": "weapontype",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "eventid",
      "type": "esriFieldTypeString",
      "alias": "eventid",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    },
    {
      "name": "eventsummary",
      "type": "esriFieldTypeString",
      "alias": "eventsummary",
      "length": null,
      "editable": false,
      "nullable": true,
      "domain": null
    }
  ],
  "relationships": [

  ],
  "canModifyLayer": false,
  "canScaleSymbols": false,
  "hasLabels": false,
  "capabilities": "Query",
  "maxRecordCount": 100000,
  "supportsStatistics": true,
  "supportsAdvancedQueries": true,
  "supportedQueryFormats": "JSON",
  "ownershipBasedAccessControlForFeatures": {
    "allowOthersToQuery": true
  },
  "useStandardizedQueries": true,
  "advancedQueryCapabilities": {
    "useStandardizedQueries": true,
    "supportsStatistics": true,
    "supportsOrderBy": true,
    "supportsDistinct": true,
    "supportsPagination": false,
    "supportsTrueCurve": false,
    "supportsReturningQueryExtent": true,
    "supportsQueryWithDistance": true
  },
  "dateFieldsTimeReference": null,
  "isDataVersioned": false,
  "supportsRollbackOnFailureParameter": true,
  "hasM": false,
  "hasZ": false,
  "allowGeometryUpdates": true,
  "objectIdField": "OBJECTID",
  "globalIdField": "",
  "types": [

  ],
  "templates": [

  ],
  "hasStaticData": true
}

Note that the requested layer was 3 but the id returned in the response is 0.

thomas-hervey commented 7 years ago

@jkerr5, working on this now. Should be fixed shortly.

thomas-hervey commented 7 years ago

@jkerr5, this should be fixed in FeatureServer@2.3.8

jkerr5 commented 7 years ago

This looks good but I now get the following error running 2.3.8:

{"error":"createFieldAliases is not a function"}

This is the stack

{ f: 'json',
  where: '1=1',
  groupByFieldsForStatistics: 'urllangcode',
  outStatistics: '[{"statisticType":"count","onStatisticField":"OBJECTID","outStatisticFieldName":"count_2"}]',
  callback: 'dojo.io.script.jsonp_dojoIoScript77._jsonpCallback' }
Provider elapsed time: 1956
Trace: TypeError: createFieldAliases is not a function
    at renderStats (/home/jkerr/projects/koop-provider-marklogic/node_modules/featureserver/dist/templates.js:114:19)
    at query (/home/jkerr/projects/koop-provider-marklogic/node_modules/featureserver/dist/query.js:23:33)
    at execQuery (/home/jkerr/projects/koop-provider-marklogic/node_modules/featureserver/dist/route.js:36:16)
    at Object.route (/home/jkerr/projects/koop-provider-marklogic/node_modules/featureserver/dist/route.js:27:14)
    at /home/jkerr/projects/koop-provider-marklogic/node_modules/koop-output-geoservices/index.js:9:24
    at /home/jkerr/projects/koop-provider-marklogic/node_modules/koop/dist/models/index.js:15:9
    at mq.providerGetData.then.data (/home/jkerr/projects/koop-provider-marklogic/marklogic.js:40:8)
    at execQuery (/home/jkerr/projects/koop-provider-marklogic/node_modules/featureserver/dist/route.js:38:52)
    at Object.route (/home/jkerr/projects/koop-provider-marklogic/node_modules/featureserver/dist/route.js:27:14)
    at /home/jkerr/projects/koop-provider-marklogic/node_modules/koop-output-geoservices/index.js:9:24
    at /home/jkerr/projects/koop-provider-marklogic/node_modules/koop/dist/models/index.js:15:9
    at mq.providerGetData.then.data (/home/jkerr/projects/koop-provider-marklogic/marklogic.js:40:8)

None of the statistics calls work anymore. Reverting back to featureserver@2.3.7 and this issue goes away.

Do you want a new issue?

thomas-hervey commented 7 years ago

@jkerr5, no need for a new issue. I am taking a look at this now.

thomas-hervey commented 7 years ago

@jkerr5, I believe this was a build error. It should be fixed in featureserver@2.3.10. Let me know if it persists.

jkerr5 commented 7 years ago

Looks good. Thanks.