GeoJSON class
The GeoJSON text format for coordinate, geometry and feature objects.
Rules applied by the format conforms with the GeoJSON formatting of coordinate lists and geometries.
Examples:
- point (x, y):
{"type":"Point","coordinates":[10.1,20.2]}
- point (x, y, z):
{"type":"Point","coordinates":[10.1,20.2,30.3]}
- box (min-x, min-y, max-x, max-y), as a property inside other object:
"bbox": [10.1,10.1,20.2,20.2]
- box (min-x, min-y, min-z, max-x, max-y, maz-z), as a property:
"bbox": [10.1,10.1,10.1,20.2,20.2,20.2]
Multi point (with 2D points):
{"type":"MultiPoint","coordinates":[[10.1,10.1],[20.2,20.2],[30.3,30.3]]}
Line string (with 2D points):
{"type":"LineString","coordinates":[[10.1,10.1],[20.2,20.2],[30.3,30.3]]}
Multi line string (with 2D points):
{"type":"MultiLineString",
"coordinates":[[[10.1,10.1],[20.2,20.2],[30.3,30.3]]]}
Polygon (with 2D points):
{"type":"Polygon",
"coordinates":[[[35,10],[45,45],[15,40],[10,20],[35,10]]]}
MultiPolygon (with 2D points):
{"type":"Polygon",
"coordinates":[[[[35,10],[45,45],[15,40],[10,20],[35,10]]]]}
Feature:
{"type": "Feature",
"id":1,
"properties": {"prop1": 100},
"geometry": {"type":"Point","coordinates":[10.1,20.2]}}
The GeoJSON specification about M coordinates: "Implementations SHOULD NOT extend positions beyond three elements because the semantics of extra elements are unspecified and ambiguous. Historically, some implementations have used a fourth element to carry a linear referencing measure (sometimes denoted as "M") or a numerical timestamp, but in most situations a parser will not be able to properly interpret these values. The interpretation and meaning of additional elements is beyond the scope of this specification, and additional elements MAY be ignored by parsers."
This implementation allows printing M coordinates, when available on source data. Such M coordinate values are always formatted as "fourth element.". However, it's possible that other implementations cannot read them:
- point (x, y, m), with z missing but formatted as 0, and m = 40.4:
{"type":"Point","coordinates":[10.1,20.2,0,40.4]}
- point (x, y, z, m), with z = 30.3 and m = 40.4:
{"type":"Point","coordinates":[10.1,20.2,30.3,40.4]}
When getting an encoder from text writer format objects this GeoJSON
class provides you can use crs
parameter to give hints (like axis order,
and whether x and y must be swapped when writing) about coordinate reference
system in text output. When crs
is available then crs.swapXY
is used to
determine whether swapping (x/longitude <-> y/latitude) should occur.
Constructors
- GeoJSON()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
coordinateFormat(
{GeoJsonConf? conf}) → TextWriterFormat< CoordinateContent> -
The GeoJSON text format (encoding only) for coordinate objects with
optional
conf
. -
featureFormat(
{GeoJsonConf? conf}) → TextFormat< FeatureContent> -
The GeoJSON text format (encoding and decoding) for feature objects with
optional
conf
. -
geometryFormat(
{GeoJsonConf? conf}) → TextFormat< GeometryContent> -
The GeoJSON text format (encoding and decoding) for geometry objects with
optional
conf
.
Constants
-
coordinate
→ const TextWriterFormat<
CoordinateContent> - The GeoJSON text format (encoding only) for coordinate objects.
-
feature
→ const TextFormat<
FeatureContent> - The GeoJSON text format (encoding and decoding) for feature objects.
-
geometry
→ const TextFormat<
GeometryContent> - The GeoJSON text format (encoding and decoding) for geometry objects.