JS API
Map Object
QueryEngine Object
Layer Object
Feature Object
Query Object
GeoJson Function Library (Experimental)

Methods

bufferGeometry

Creates an filter that buffers geometry. Buffering geometry converts the geometry to the polygon type in the case of points or lines. The geometry is the essentially "inflated" by the factor that is provided.

Parameters

Name Required Description
factor Yes the factor represents a size (in degrees) by which to buffer (inflate) the geometry.
options No An object for the configuration of the bufferGeometry filter. The possible options are shown in the section below.

Options

Name Default Description
side "both" This option applies only to buffering of line layers. It determines the side of the line that the buffering is done.

Valid values for this option are:
- "both"
- "left"
- "right"
- "inner"
- "outer"
joins "round" This option applies only to buffering of line layers. It describes how the joins (elbows) of the line should be buffered.

Valid values for this option are:
- "round"
- "mitred"
- "bevel"
ends "round" This option applies only to buffering of line layers. It describes how the ends of the line should be buffered.

Valid values for this option are:
- "round"
- "square"
- "flat"
mitreLimit This option applies only to buffering of line layers. It is only applicable in the case of joins="mitred". It sets the limit of the mitre.

Example

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("PRIMARY_ROADS")
    .bufferGeometry(0.010, {side:"left", joins:"bevel", ends:"flat"})
    .apply()
    .then(function(data){
        console.log(data);
    });

changeProperties

Creates an filter that restricts, adds or changes the feature properties. This is analogous to the SELECT clause of a SQL query.

Parameters

Name Required Description
properties Yes Accepts either an array of strings or a comma-delimited string. Each string is a property definition in the following format:

expression AS/as/As property-name
or
expression

If the "AS property-name' clause is excluded, the name of the property will be the underlying property in the expression, if it is simply the property name or automatically generated if it is an expression or built-in keyword.

Expressions can be anything that is valid for the filterByText filter.

A number of built-in keywords exist:
- Area() - This returns an the area of the geometry related to the feature.
- Length() - This returns the length of the geometry related to the feature.

Example

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
    .changeProperties(["Name", "Region", "Area()"])
    .apply()
    .then(function(data){
        console.log(data);
    });

qry.usingLayerSource("COUNTRIES")
    .changeProperties("Name AS 'Country Name'")
    .apply()
    .then(function(data){
        console.log(data);
    });

qry.usingLayerSource("COUNTRIES")
    .changeProperties("Format(Population / Area(), '#,###.0') as Density")
    .apply()
    .then(function(data){
        console.log(data);
    });

qry.usingLayerSource("COUNTRIES")
    .changeProperties("Population / Area()")
    .apply()
    .then(function(data){
        console.log(data);
    });

qry.usingLayerSource("COUNTRIES")
    .changeProperties("Area() As 'MyArea', Length()" As 'MyLength')
    .apply()
    .then(function(data){
        console.log(data);
    });

clipByFeatureCollection

Creates an filter that clips features based on whether or not they are inside of a GeoJSON FeatureCollection.

Parameters

Name Required Description
featureCollection Yes A GeoJSON FeatureCollection.

Example

var featureCollection = {
  type:"FeatureCollection",
  features: [
    {
      type: "Feature",    
      geometry: {
        coordinates: [
          [
            [4.88922, 52.37072],
            [4.89526, 52.37114],
            [4.89209, 52.36931],
            [4.88925, 52.37072]
          ]
        ],
        type: "Polygon"
      }
    }
  ]
};

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
  .clipByFeatureCollection(featureCollection)
  .apply()
  .then(function(data){
        console.log(data);
   });

convertToCentroids

Creates an filter that converts all geometry to a point that represents its centroid.

Parameters

No parameters.

Example

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
  .convertToCentroids()
  .apply()
  .then(function(data){
        console.log(data);
   });

filterByBoundingBox

Creates an filter that filters features based on a bounding box.

Parameters

Name Required Description
bbox Yes The bounding box by which features are filtered.

The format of the bbox parameter is an array of numbers and conforms to the GeoJSON standard for a bounding box i.e. [minX, minY, maxX, maxY] where:

- minX (The minimum x-value of the bounding box)
- minY (The minimum y-value of the bounding box)
- maxX (The maximum x-value of the bounding box)
- maxY (The maximum y-value of the bounding box)

Example

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
  .filterByBoundingBox([12.4, 9.5, 24.6, 41.2])
  .apply()
  .then(function(data){
        console.log(data);
   }); 

filterByFeatureCollection

Creates an filter that filters features based on whether or not they are contained by a GeoJSON FeatureCollection.

Parameters

Name Required Description
features Yes A GeoJSON FeatureCollection.
options No An object for the configuration of the filterByFeatureCollection filter. The possible options are shown in the section below.

Options

Name Default Description
operator 'intersects' Defines the spatial operator that will be applied in the filter. Possible values are:
- 'intersects'
- 'contains'
- 'crosses'

Example

var featureCollection = {
  type:"FeatureCollection",
  features: [
    {
      type: "Feature",    
      geometry: {
        coordinates: [
          [
            [4.88922, 52.37072],
            [4.89526, 52.37114],
            [4.89209, 52.36931],
            [4.88925, 52.37072]
          ]
        ],
        type: "Polygon"
      }
    }
  ]
};

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
  .filterByFeatureCollection(featureCollection);
  .apply()
  .then(function(data){
        console.log(data);
   });

filterByNearest

Creates an filter that filters features based on their proximity to a point (latitude, longitude).

Parameters

Name Required Description
point Yes The GeoJSON Point from which to test proximity. latitude value of the coordinate.
options No An object for the configuration of the filterByNearest filter. The possible options are shown in the section below.

Options

Name Default Description
take 1 The number of features to return.
includeDistance false If this is true, the distance to each feature is added as a property to the feature

Example


var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
  .filterByNearest({type:"Point", coordinates:[10.2, -12.5]}, {take:3})
  .apply()
  .then(function(data){
        console.log(data);
   });

filterByText

Creates an filter that filters features based on a text-based query statement. This is analogous to the WHERE clause of a SQL query.

Parameters

Name Required Description
statement Yes The text-based query statement.

The following operators are supported:
- Logical: or, ||, and, &&
- Relational: =, ==, !=, <>, <, >, <=, >=
- Unary: !, not
- Arithmetic: +, -, *, /, %
- Bitwise: &, |, ^, <<, >>, ~

The following mathematical functions are supported:
- Numeric: Ceiling, Exp, Floor, Log, Log10, Max, Min, Pow, Round, Sign, Sqrt, Truncate
- Trigonometric: Acos, Asin, Atan, Cos, Sin, Tan

The following built-in functions are supported:
- Like(item-to-compare, comparison-expression) e.g. Like(NAME, 'John%')
- In(item, list-of-items) e.g. In(NAME, 'Fred', 'John', 'Pete')
- Format(item, format-string) e.g. Format(DATE, 'yyyy-MM-dd')

Example

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
  .filterByText("LandLocked=='Y'")
  .apply()
  .then(function(data){
        console.log(data);
   });

apply

This method runs the query that has been built up by chaining filters on the Query object.

It returns a promise with the filtered feature-collection.

Parameters

No parameters.

Example

var qry = new Mapzania.QueryEngine();

qry.usingLayerSource("COUNTRIES")
  .filterByText("LandLocked=='Y'")
  .convertToCentroids()
  .bufferGeometry(500)
  .apply()
  .then(function(data){
        console.log(data);
   });