/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using MongoDB.Bson;
namespace MongoDB.Driver.GeoJsonObjectModel
{
///
/// A static class containing helper methods to create GeoJson objects.
///
public static class GeoJson
{
// public static methods
///
/// Creates a GeoJson bounding box.
///
/// The type of the coordinates.
/// The min.
/// The max.
/// A GeoJson bounding box.
public static GeoJsonBoundingBox BoundingBox(TCoordinates min, TCoordinates max) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonBoundingBox(min, max);
}
///
/// Creates a GeoJson Feature object.
///
/// The type of the coordinates.
/// The geometry.
/// A GeoJson Feature object.
public static GeoJsonFeature Feature(GeoJsonGeometry geometry) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonFeature(geometry);
}
///
/// Creates a GeoJson Feature object.
///
/// The type of the coordinates.
/// The additional args.
/// The geometry.
/// A GeoJson Feature object.
public static GeoJsonFeature Feature(GeoJsonFeatureArgs args, GeoJsonGeometry geometry) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonFeature(args, geometry);
}
///
/// Creates a GeoJson FeatureCollection object.
///
/// The type of the coordinates.
/// The additional args.
/// The features.
/// A GeoJson FeatureCollection object.
public static GeoJsonFeatureCollection FeatureCollection(GeoJsonObjectArgs args, params GeoJsonFeature[] features) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonFeatureCollection(args, features);
}
///
/// Creates a GeoJson FeatureCollection object.
///
/// The type of the coordinates.
/// The features.
/// A GeoJson FeatureCollection object.
public static GeoJsonFeatureCollection FeatureCollection(params GeoJsonFeature[] features) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonFeatureCollection(features);
}
///
/// Creates a GeoJson 2D geographic position (longitude, latitude).
///
/// The longitude.
/// The latitude.
/// A GeoJson 2D geographic position.
public static GeoJson2DGeographicCoordinates Geographic(double longitude, double latitude)
{
return new GeoJson2DGeographicCoordinates(longitude, latitude);
}
///
/// Creates a GeoJson 3D geographic position (longitude, latitude, altitude).
///
/// The longitude.
/// The latitude.
/// The altitude.
/// A GeoJson 3D geographic position.
public static GeoJson3DGeographicCoordinates Geographic(double longitude, double latitude, double altitude)
{
return new GeoJson3DGeographicCoordinates(longitude, latitude, altitude);
}
///
/// Creates a GeoJson GeometryCollection object.
///
/// The type of the coordinates.
/// The additional args.
/// The geometries.
/// A GeoJson GeometryCollection object.
public static GeoJsonGeometryCollection GeometryCollection(GeoJsonObjectArgs args, params GeoJsonGeometry[] geometries) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonGeometryCollection(args, geometries);
}
///
/// Creates a GeoJson GeometryCollection object.
///
/// The type of the coordinates.
/// The geometries.
/// A GeoJson GeometryCollection object.
public static GeoJsonGeometryCollection GeometryCollection(params GeoJsonGeometry[] geometries) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonGeometryCollection(geometries);
}
///
/// Creates the coordinates of a GeoJson linear ring.
///
/// The type of the coordinates.
/// The positions.
/// The coordinates of a GeoJson linear ring.
public static GeoJsonLinearRingCoordinates LinearRingCoordinates(params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonLinearRingCoordinates(positions);
}
///
/// Creates a GeoJson LineString object.
///
/// The type of the coordinates.
/// The additional args.
/// The positions.
/// A GeoJson LineString object.
public static GeoJsonLineString LineString(GeoJsonObjectArgs args, params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonLineStringCoordinates(positions);
return new GeoJsonLineString(args, coordinates);
}
///
/// Creates a GeoJson LineString object.
///
/// The type of the coordinates.
/// The positions.
/// A GeoJson LineString object.
public static GeoJsonLineString LineString(params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonLineStringCoordinates(positions);
return new GeoJsonLineString(coordinates);
}
///
/// Creates the coordinates of a GeoJson LineString.
///
/// The type of the coordinates.
/// The positions.
/// The coordinates of a GeoJson LineString.
public static GeoJsonLineStringCoordinates LineStringCoordinates(params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonLineStringCoordinates(positions);
}
///
/// Creates a GeoJson MultiLineString object.
///
/// The type of the coordinates.
/// The additional args.
/// The line strings.
/// A GeoJson MultiLineString object.
public static GeoJsonMultiLineString MultiLineString(GeoJsonObjectArgs args, params GeoJsonLineStringCoordinates[] lineStrings) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonMultiLineStringCoordinates(lineStrings);
return new GeoJsonMultiLineString(args, coordinates);
}
///
/// Creates a GeoJson MultiLineString object.
///
/// The type of the coordinates.
/// The line strings.
/// A GeoJson MultiLineString object.
public static GeoJsonMultiLineString MultiLineString(params GeoJsonLineStringCoordinates[] lineStrings) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonMultiLineStringCoordinates(lineStrings);
return new GeoJsonMultiLineString(coordinates);
}
///
/// Creates a GeoJson MultiPoint object.
///
/// The type of the coordinates.
/// The additional args.
/// The positions.
/// A GeoJson MultiPoint object.
public static GeoJsonMultiPoint MultiPoint(GeoJsonObjectArgs args, params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonMultiPointCoordinates(positions);
return new GeoJsonMultiPoint(args, coordinates);
}
///
/// Creates a GeoJson MultiPoint object.
///
/// The type of the coordinates.
/// The positions.
/// A GeoJson MultiPoint object.
public static GeoJsonMultiPoint MultiPoint(params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonMultiPointCoordinates(positions);
return new GeoJsonMultiPoint(coordinates);
}
///
/// Creates a GeoJson MultiPolygon object.
///
/// The type of the coordinates.
/// The additional args.
/// The polygons.
/// A GeoJson MultiPolygon object.
public static GeoJsonMultiPolygon MultiPolygon(GeoJsonObjectArgs args, params GeoJsonPolygonCoordinates[] polygons) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonMultiPolygonCoordinates(polygons);
return new GeoJsonMultiPolygon(args, coordinates);
}
///
/// Creates a GeoJson MultiPolygon object.
///
/// The type of the coordinates.
/// The polygons.
/// A GeoJson MultiPolygon object.
public static GeoJsonMultiPolygon MultiPolygon(params GeoJsonPolygonCoordinates[] polygons) where TCoordinates : GeoJsonCoordinates
{
var coordinates = new GeoJsonMultiPolygonCoordinates(polygons);
return new GeoJsonMultiPolygon(coordinates);
}
///
/// Creates a GeoJson Point object.
///
/// The type of the coordinates.
/// The additional args.
/// The coordinates.
/// A GeoJson Point object.
public static GeoJsonPoint Point(GeoJsonObjectArgs args, TCoordinates coordinates) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonPoint(args, coordinates);
}
///
/// Creates a GeoJson Point object.
///
/// The type of the coordinates.
/// The coordinates.
/// A GeoJson Point object.
public static GeoJsonPoint Point(TCoordinates coordinates) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonPoint(coordinates);
}
///
/// Creates a GeoJson Polygon object.
///
/// The type of the coordinates.
/// The additional args.
/// The positions.
/// A GeoJson Polygon object.
public static GeoJsonPolygon Polygon(GeoJsonObjectArgs args, params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
var exterior = new GeoJsonLinearRingCoordinates(positions);
var coordinates = new GeoJsonPolygonCoordinates(exterior);
return new GeoJsonPolygon(args, coordinates);
}
///
/// Creates a GeoJson Polygon object.
///
/// The type of the coordinates.
/// The additional args.
/// The coordinates.
/// A GeoJson Polygon object.
public static GeoJsonPolygon Polygon(GeoJsonObjectArgs args, GeoJsonPolygonCoordinates coordinates) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonPolygon(args, coordinates);
}
///
/// Creates a GeoJson Polygon object.
///
/// The type of the coordinates.
/// The coordinates.
/// A GeoJson Polygon object.
public static GeoJsonPolygon Polygon(GeoJsonPolygonCoordinates coordinates) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonPolygon(coordinates);
}
///
/// Creates a GeoJson Polygon object.
///
/// The type of the coordinates.
/// The positions.
/// A GeoJson Polygon object.
public static GeoJsonPolygon Polygon(params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
var exterior = new GeoJsonLinearRingCoordinates(positions);
var coordinates = new GeoJsonPolygonCoordinates(exterior);
return new GeoJsonPolygon(coordinates);
}
///
/// Creates the coordinates of a GeoJson Polygon object.
///
/// The type of the coordinates.
/// The positions.
/// The coordinates of a GeoJson Polygon object.
public static GeoJsonPolygonCoordinates PolygonCoordinates(params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates
{
var exterior = new GeoJsonLinearRingCoordinates(positions);
return new GeoJsonPolygonCoordinates(exterior);
}
///
/// Creates the coordinates of a GeoJson Polygon object.
///
/// The type of the coordinates.
/// The exterior.
/// The holes.
/// The coordinates of a GeoJson Polygon object.
public static GeoJsonPolygonCoordinates PolygonCoordinates(GeoJsonLinearRingCoordinates exterior, params GeoJsonLinearRingCoordinates[] holes) where TCoordinates : GeoJsonCoordinates
{
return new GeoJsonPolygonCoordinates(exterior, holes);
}
///
/// Creates a GeoJson 2D position (x, y).
///
/// The x.
/// The y.
/// A GeoJson 2D position.
public static GeoJson2DCoordinates Position(double x, double y)
{
return new GeoJson2DCoordinates(x, y);
}
///
/// Creates a GeoJson 3D position (x, y, z).
///
/// The x.
/// The y.
/// The z.
/// A GeoJson 3D position.
public static GeoJson3DCoordinates Position(double x, double y, double z)
{
return new GeoJson3DCoordinates(x, y, z);
}
///
/// Creates a GeoJson 2D projected position (easting, northing).
///
/// The easting.
/// The northing.
/// A GeoJson 2D projected position.
public static GeoJson2DProjectedCoordinates Projected(double easting, double northing)
{
return new GeoJson2DProjectedCoordinates(easting, northing);
}
///
/// Creates a GeoJson 3D projected position (easting, northing, altitude).
///
/// The easting.
/// The northing.
/// The altitude.
/// A GeoJson 3D projected position.
public static GeoJson3DProjectedCoordinates Projected(double easting, double northing, double altitude)
{
return new GeoJson3DProjectedCoordinates(easting, northing, altitude);
}
}
}