Skip to content

Custom Format

Preston edited this page Oct 30, 2019 · 1 revision

Not all data comes in a GeoJSON or WKT format. For documents that have their own formats, we can create our own custom geospatial data extractor through configuration.

Sample document

{
  "type": "Apartment",
  "status": "Move in read",
  "amenities": [
    "pool",
    "pet-friendly",
  ],
  "address": {
    "street": "123 Main Street",
    "state": "BR",
    "zipCode": "829134",
    "_metadata": {
      "propertyLocation": "28.839,-104.1352"
    }
  }
}

The Feature Layer to pull out the propertyLocation can be specified as a geometry/indexes/elementChild. The index for this elementChild needs to be created in your ml-config if you are using ml-gradle or directly on the content's database. The settings for the index should match what was used to create the index. The extractor code will make use of the provided values in the Feature Layer configuration to identify the matching index. If the index cannot be found, the marklogic-geo-data-services will throw an error.

Example Feature Layer

{
  "info" : {
    "name" : "CustomDataFormat",
    "description" : "Lets show off a custom data format that is not GeoJSON or WKT"
  },
  "layers" : [
    {
      "id": 0,
      "name" : "Apartments",
      "description": "All Apartments",
      "geometryType": "Point",
      "idField": "OBJECTID",
      "displayField": "LABEL",
      "extent": {
        "xmin": -180,
        "ymin": -90,
        "xmax": 180,
        "ymax": 90,
        "spatialReference": {
          "wkid": 4326,
          "latestWkid": 4326
        }
      },
      "schema" : "Realestate",
      "view" : "Apartments",
      "geometry" : {
        "type" : "Point",
        "format" : "custom",
        "coordinateSystem" : "wgs84",
        "xpath" : "//*:propertyLocation",
        "indexes": {
          "elementChild": [
            {
              "parentNamespaceUri": "",
              "parentLocalname": "_metadata",
              "namespaceUri": "",
              "localname": "propertyLocation",
              "pointFormat": "point",
              "coordinateSystem": "wgs84"
            }
          ]
        }
      }
    }
  ]
}
Clone this wiki locally