Crate s2json

Crate s2json 

Source
Expand description

§S2 JSON 🌎 🗺️

                ________              
               / ___/__ \             
               \__ \__/ /             
              ___/ / __/              
             /____/____/              
                                       
            _______ ____  _   __      
           / / ___// __ \/ | / /      
      __  / /\__ \/ / / /  |/ /       
     / /_/ /___/ / /_/ / /|  /        
     \____//____/\____/_/ |_/         

§Install

cargo add s2json

§About

A collection of geospatial base types primarily designed for WGS84, Web Mercator, and S2.

This library is designed to be lightweight with minimal dependencies. All code is no_std complient, denies unsafe code, and can be used in any environment.

§Usage

The Documentation is very thorough in this library. Therefore the best thing to do is follow the links provided as needed.

This library wraps both a GeoJSON spec and the newer S2 JSON spec. For tooling that builds ontop of this library, see gis-tools.

§Core

§Top Level Topology
§Bounding Boxes
  • crate::BBox: A BBOX is defined in lon-lat space and helps with zooming motion to see the entire line or polygon The order is (left, bottom, right, top) If WM, then the projection is lon-lat If S2, then the projection is s-t
  • crate::BBox3D: A BBOX is defined in lon-lat space and helps with zooming motion to see the entire 3D line or polygon
  • crate::BBOX: BBox or BBox3D enum
§Primitive Types

Note that [crate::MValue] is the key type used by the rest of the library, gis-tools, s2tiles, s2maps, etc. Allows a lot of cool encoding/decoding mechanics along with better rendering tools.

§Geoemtry

Primitives

Vector Primitives

§Traits

These traits are the fundamental building box for all geometry tooling. If you need your own custom data structure you can implement these traits and use all the tools built not only in this library but gis-tools as well.

Getters

Setters

New

  • crate::NewXY: Get and Set the X and Y coordinates of a point
  • crate::NewXYM: Get and Set the X, Y, and M coordinates of a point
  • crate::NewXYZ: Get and Set the X, Y, and Z coordinates of a point
  • crate::NewXYZM: Get and Set the X, Y, Z, and M coordinates of a point

Full Get, New, and Set

  • crate::FullXY: Get, New, and Set the X and Y coordinates of a point
  • crate::FullXYM: Get, New, and Set the X, Y, and M coordinates of a point
  • crate::FullXYZ: Get, New, and Set the X, Y, and Z coordinates of a point
  • crate::FullXYZM: Get, New, and Set the X, Y, Z, and M coordinates of a point

Utilities

You probably won’t have to implement these. Created for convenience.

§Derives

  • crate::MValueCompatible: Ensure M implements All MValue Traits used by VectorPoints
  • crate::JSONPropertiesCompatible: Ensure M implements All MValue Traits used by complex GeoJSON properties. Not used by gis-tools.
  • [crate::Properties]: Ensure M implements All MValue Traits used by VectorPoints
  • [crate::MValue]: Ensure M implements All MValue Traits used by VectorPoints
  • [crate::ValuePrimitive]: Sub type used by [crate::MValue]
  • [crate::JSONProperties]: JSON Properties specification to-from mechanics

Modules§

geometry
All geometry types and structs
impls
All json, value, shape impl
map
BTreeMap wrapper
shape
All shape types and structs
value
All values types and structs

Structs§

BBox
Bounding Box
BBox3D
3D Bounding Box
BaseGeometry
BaseGeometry is the a generic geometry type
Feature
Component to build an WG Feature
FeatureCollection
WG FeatureCollection
Map
A BTreeMap wrapper
Point
Definition of a Point. May represent WebMercator Lon-Lat or S2Geometry S-T
Point3D
Definition of a 3D Point. May represent WebMercator Lon-Lat or S2Geometry S-T with a z-value
PointOrPoint3D
Define a Point or Point3D
S2FeatureCollection
S2 FeatureCollection
STPoint
A Point in S2 Space with a Face
VectorBaseGeometry
BaseGeometry is the a generic geometry type
VectorFeature
Component to build an WG or S2 Vector Feature
VectorPoint
Vector Points

Enums§

Axis
The axis to apply an operation to
BBOX
BBox or BBox3D
Face
Cube-face on the S2 sphere
FeatureCollectionType
FeatureCollection type string
FeatureCollections
Either an S2 or WG FeatureCollection
FeatureType
Feature type string
Features
Either an S2, Vector WG or WG Feature
Geometry
All possible geometry shapes
GeometryType
Enum to represent specific geometry types as strings
JSONCollection
All major GeoJSON and S2JSON types
JSONValue
All possible JSON shapes
MValues
All possible M-Value shapes
PrimitiveShape
Primitive types that can be found in a shape
PrimitiveShapeType
Arrays may contain either a primitive or an object whose values are primitives
PrimitiveValue
Primitive types supported by Properties
Projection
All projections that can be used
S2FeatureCollectionType
FeatureCollection type string
ShapeType
Shape types that can be found in a shapes object. Either a primitive, an array containing any type, or a nested shape. If the type is an array, all elements must be the same type
ValuePrimitiveType
Arrays may contain either a primitive or an object whose values are primitives
ValueType
Supports primitive types string, number, boolean, null May be an array of those primitive types, or an object whose values are only primitives Object keys are always strings, values can be any basic type, an array, or a nested object. Array values must all be the same type.
VectorFeatureType
Feature type string
VectorGeometry
Vector Geometry
VectorGeometryType
Enum to represent specific vector geometry types as strings
VectorOffsets
All possible geometry offsets

Traits§

Bounded
Trait for types that have a min and max value. Used by BBox and BBox3D
FullXY
Composite Trait for XY use cases
FullXYM
Composite Trait for XYM use cases
FullXYZ
Composite Trait for XYZ use cases
FullXYZM
Composite Trait for XYZM use cases
GetM
Trait to extract the m value
GetXY
Trait to extract the x and y values
GetXYM
Composite Trait: XY + M
GetXYZ
Composite Trait: XY + Z
GetXYZM
Composite Trait: XY + Z + M
GetZ
Trait to extract the z value
Interpolate
Easy access to interpolation tooling for All S2JSON Core Types
JSONPropertiesCompatible
Ensure M implements MValueCompatible
MValueCompatible
Ensure M implements MValueCompatible
NewXY
Trait to create a new XY
NewXYM
Trait to create a new XY
NewXYZ
Trait to create a new XYZ
NewXYZM
Trait to create a new XYZM
SetM
Trait to set the m value
SetXY
Trait to set the x and y values
SetXYM
Composite Trait: XY + M
SetXYZ
Composite Trait: XY + Z
SetXYZM
Composite Trait: XY + Z + M
SetZ
Trait to set the z value

Type Aliases§

Attributions
Attribution data is stored in an object. The key is the name of the attribution, and the value is the href link e.g. { “Open S2”: “https://opens2.com/legal/data” }
JSONProperties
Shape of an un-restricted features properties object
LineString
Definition of a LineString
LineString3D
Definition of a 3D LineString
LineString3DGeometry
LineString3DGeometry is a 3D line
LineStringGeometry
LineStringGeometry is a line
LineStringMValues
LineString Properties Shape
MValue
Shape of a feature’s M-Values object
MapboxProperties
Shape of the restricted Mapbox properties object
MultiLineString
Definition of a MultiLineString
MultiLineString3D
Definition of a 3D MultiLineString
MultiLineString3DGeometry
MultiLineString3DGeometry contains multiple 3D lines
MultiLineStringGeometry
MultiLineStringGeometry contains multiple lines
MultiLineStringMValues
MultiLineString MValues Shape
MultiPoint
Definition of a MultiPoint
MultiPoint3D
Definition of a 3D MultiPoint
MultiPoint3DGeometry
MultiPoint3DGeometry contains multiple 3D points
MultiPointGeometry
MultiPointGeometry contains multiple points
MultiPolygon
Definition of a MultiPolygon
MultiPolygon3D
Definition of a 3D MultiPolygon
MultiPolygon3DGeometry
MultiPolygon3DGeometry is a 3D polygon with multiple polygons with their own potential holes
MultiPolygonGeometry
MultiPolygonGeometry is a polygon with multiple polygons with their own potential holes
MultiPolygonMValues
MultiPolygon MValues Shape
Point3DGeometry
Point3DGeometry is a 3D point
PointGeometry
PointGeometry is a point
Polygon
Definition of a Polygon
Polygon3D
Definition of a 3D Polygon
Polygon3DGeometry
Polygon3DGeometry is a 3D polygon with potential holes
PolygonGeometry
PolygonGeometry is a polygon with potential holes
PolygonMValues
Polygon MValues Shape
Properties
Shape of a features properties object
Shape
The Shape Object
ShapePrimitive
The Primitive Shape Object
Value
Shape design
ValuePrimitive
Shape of a ValuePrimitiveType Nested object
VectorLineOffset
An offset defines how far the starting line is from the original starting point pre-slice
VectorLineString
Definition of a Vector LineString
VectorLineStringGeometry
LineStringGeometry is a line
VectorMultiLineOffset
A collection of offsets
VectorMultiLineString
Definition of a Vector MultiLineString
VectorMultiLineStringGeometry
MultiLineStringGeometry contains multiple lines
VectorMultiPoint
Definition of a Vector MultiPoint
VectorMultiPointGeometry
MultiPointGeometry contains multiple points
VectorMultiPolygon
Definition of a Vector MultiPolygon
VectorMultiPolygonGeometry
MultiPolygonGeometry is a polygon with multiple polygons with their own potential holes
VectorMultiPolygonOffset
A collection of collections of offsets
VectorPointGeometry
PointGeometry is a point
VectorPolygon
Definition of a Vector Polygon
VectorPolygonGeometry
PolygonGeometry is a polygon with potential holes
VectorPolygonOffset
A collection of offsets

Derive Macros§

JSONPropertiesderive
Derives the JSONProperties trait for a struct to convert it to a JSONProperties.
MValuederive
Derives the MValue trait for a struct to convert it to a MValue.
MValueCompatiblederive
Derives the MValueCompatible trait for a struct to convert it to a MValue.
Propertiesderive
Derives the Properties trait for a struct to convert it to a Properties.
ValuePrimitivederive
Derives the ValuePrimitive trait for a struct to convert it to a ValuePrimitive.