Back to Devexpress

Provide Cartesian Data to a Geographical Map

windowsforms-18181-controls-and-libraries-map-control-coordinate-systems-provide-cartesian-data-to-a-geographical-map.md

latest4.7 KB
Original Source

Provide Cartesian Data to a Geographical Map

  • Nov 24, 2022
  • 2 minutes to read

This document describes how to load Cartesian coordinate data onto a geographical map. The document consists of the following sections.

Overview

The CoordinateSystemDataAdapterBase class descendants allow you to provide both Cartesian and geographical map data. To specify which kind of data the adapter should provide, customize the CoordinateSystemDataAdapterBase.SourceCoordinateSystem property.

By default, this property is set to GeoSourceCoordinateSystem and to load Cartesian data, assign an CartesianSourceCoordinateSystem object to this property.

Load Coordinate System from the *.PRJ File

If your data contains the *.PRJ file and this file is located in the same directory and has the same name as a shapefile, the coordinate system will be loaded automatically. Otherwise, if the paths or the names are different, call the ShapefileDataAdapter.LoadPrjFile or ShapefileDataAdapter.LoadPrjFromStream method to load coordinate system metadata.

The following code demonstrates how to load the projection information using the LoadPrjFile method.

csharp
data.Add(new MapData() {
    Name = "LoadPrjFile( ) calling loaded coordinate system",
    FileUri = new Uri(baseUri, "../../Shapefiles/Lambert/Belize.shp"),
    CoordinateSystem = ShapefileDataAdapter.LoadPrjFile(new Uri(
        baseUri,
        "../../Shapefiles/Lambert/Projection.prj"))
});
vb
data.Add(New MapData() With {.Name = "LoadPrjFile( ) calling loaded coordinate system", .FileUri = New Uri(baseUri, "../../Shapefiles/Lambert/Belize.shp"), .CoordinateSystem = ShapefileDataAdapter.LoadPrjFile(New Uri(baseUri, "../../Shapefiles/Lambert/Projection.prj"))})

The following image demonstrates the result.

Specify Coordinate Converter Manually

If your data does not contain a *.PRJ file, it is possible to customize a Cartesian coordinate system manually. To do this, create a CartesianSourceCoordinateSystem object, and specify its CartesianSourceCoordinateSystem.MeasureUnit and SourceCoordinateSystem.CoordinateConverter properties. Then, assign the object to the CoordinateSystemDataAdapterBase.SourceCoordinateSystem property.

The following code demonstrates this customization.

View Example

csharp
new MapData() {
    Filepath = "../../Shapefiles/TransverseMercator/israel.shp", 
    CoordinateSystem = new CartesianSourceCoordinateSystem() {
        CoordinateConverter = new UTMCartesianToGeoConverter() {
            UtmZone = 36, Hemisphere = Hemisphere.Northern
        }
    }
},
csharp
New MapData() With { _
            .Filepath = "../../Shapefiles/TransverseMercator/israel.shp", .CoordinateSystem = New CartesianSourceCoordinateSystem() With { _
                .CoordinateConverter = New TransverseMercatorCartesianToGeoConverter() With {.Ellipsoid = Ellipsoid.WGS84, .ProjectionCenter = New GeoPoint(0, 33), .ScaleFactor = 0.9996, .FalseNorthing = 0, .FalseEasting = 500000} _
            } _
        }, _
    }

The following image demonstrates the result.

See Also

Map Coordinate Systems

Geographical Projections