How do I store the location of an object in C#

I wish to store the longitude and Latitude of an object in C# and I am wondering what could be a good way to do that. I can imagine I can simply initialize a double for longitude and latitude. In Android, there is a Location class that can be used to save the longitude and latitude of an object but I do not seem to find any like that for C#. What do you suggest I can use?

Upvotes: 3

Views: 1640

Answers (1)

Athanasios Kataras
Athanasios Kataras

Reputation: 26460

There are a couple of options here:

GeographyPoint - Represents a geography point.

Namespace information

OData stands for the Open Data Protocol. It was initiated by Microsoft and is now an ISO approved and OASIS standard. OData enables the creation and consumption of REST APIs, which allow resources, identified using URLs and defined in a data model, to be published and edited by Web clients using simple HTTP requests.

So it's mostly used for RestApis

DBGeography - Represents data in a geodetic (round earth) coordinate system.

One very handy feature of the System.Data.Spatial namespace is the DbGeography class that allows you to work with either points on a "map" or shapes/polygons.

GeoCoordinate - Represents a geographical location that is determined by latitude and longitude coordinates. May also include altitude, accuracy, speed, and course information.

Namespace information

The System.Device.Location namespace allows application developers to easily access the computer's location by using a single API. Location information may come from multiple providers, such as GPS, Wi-Fi triangulation, and cell phone tower triangulation. The System.Device.Location classes provide a single API to encapsulate the multiple location providers on a computer and support seamless prioritization and transitioning between them. As a result, application developers who use this API do not need to tailor applications to specific hardware configurations.

Upvotes: 4

Related Questions