Skybrud.Essentials.Maps is a .NET package for working with maps and geospatial data.
It also supports working with popular formats such as GeoJSON, KML (Keyhole Markup Language) and WKT (Well Known Text).
To install the Skybrud.Essentials.Maps, pick one of the methods below:
- NuGet Package
Install this NuGet package in your Visual Studio project. Makes updating easy. - ZIP file
Grab a ZIP file of the latest release; unzip and move theSkybrud.Essentials.Maps.dll
and other DLLs matching your target framework to the bin directory of your project.
-
Skybrud.Essentials
A package with logic for handling various common tasks in .NET.- Json.NET
Used for searializing/deserializing JSON.
- Json.NET
-
Skybrud.Essentials.Http
HTTP package used for resolving network links in KML files.
- Please feel free to create an issue, and I will get back to you ;)
The releases page lists the relevant changes from each release.
Define a point on a map:
// Initialize a new point by latitude and longitude
IPoint point = new Point(55.708151, 9.536131);
Calculate the distance between two points:
// Initialize the points by latitude and longitude
IPoint a = new Point(55.708151, 9.536131);
IPoint b = new Point(55.708069, 9.536000);
// Calculate the distance in metres
double distance = DistanceUtils.GetDistance(a, b);
Define a line on a map:
// Initialize the points by latitude and longitude
IPoint a = new Point(55.708151, 9.536131);
IPoint b = new Point(55.708069, 9.536000);
// Initialize a new line from the two points
ILine line = new Line(a, b);
// Get the length of the line
double length = line.GetLength();
Define a line string (polyline) on a map:
// Initialize the points by latitude and longitude
IPoint a = new Point(55.708151, 9.536131);
IPoint b = new Point(55.708069, 9.536000);
IPoint c = new Point(55.708061, 9.536172);
// Initialize a new line string from the multiple points
ILineString line = new LineString(a, b, c);
// Get the length of the line string
double length = line.GetLength();
Define a polygon on a map:
// Initialize the points by latitude and longitude
IPoint a = new Point(55.708151, 9.536131);
IPoint b = new Point(55.708069, 9.536000);
IPoint c = new Point(55.708061, 9.536172);
IPoint d = new Point(55.708145, 9.536222);
IPoint f = new Point(55.708113, 9.536086);
// Initialize a new polygon from the multiple points
IPolygon polygon = new Polygon(a, b, c, d, a);
// Get the circumferences of the polygon
double circumference = polygon.GetCircumference();
// Get the area of the polygon
double area = polygon.GetArea();
// Get the bounding of the polygon
IRectangle bbox = polygon.GetBoundingBox();
// Does the polygon contain point "f"?
bool contains = polygon.Contains(f);