ThinkGeo.com    |     Documentation    |     Premium Support

Make a map with a specific SRID

Hi,

i have the need to build a map which is completely based on srid 31466, which means that all the coordinates of all geometries are in that srid, wms-data is in that srid and “detection” of mous-coordinates should also return values based on that srid.

Is this possible?

Regards,
Andreas

Hi Andreas,

As below is a sample which shows how to show the mouse coordinates under 4326 event the map is rendered under 31466.

If you need the mouse coordinate shows under 31466, please just remove the event CustomFormatted and don’t set the MouseCoordinateType.

  private void WpfMap_Loaded(object sender, RoutedEventArgs e)
    {
        wpfMap1.MapUnit = GeographyUnit.Meter;
        WmtsLayer wmtsLayer = new WmtsLayer(new Collection<Uri> { new Uri("Your server uri") });
        wmtsLayer.Parameters.Add("LAYER", "yourlayer");
        wmtsLayer.Parameters.Add("STYLE", "default");
        wmtsLayer.Parameters.Add("FORMAT", "image/png");
        wmtsLayer.TileMatrixSetName = "EPSG:31466";

        var overlay = new LayerOverlay();
        overlay.Layers.Add(wmtsLayer);
        wpfMap1.Overlays.Add(overlay);
        wpfMap1.CurrentExtent = new RectangleShape(Your layer bouding box);

        wpfMap1.MapTools.MouseCoordinate.IsEnabled = true;
        wpfMap1.MapTools.MouseCoordinate.MouseCoordinateType = MouseCoordinateType.Custom;
        wpfMap1.MapTools.MouseCoordinate.CustomFormatted += MouseCoordinate_CustomFormatted;

        wpfMap1.Refresh();
    }

    private void MouseCoordinate_CustomFormatted(object sender, CustomFormattedMouseCoordinateMapToolEventArgs e)
    {
        var proj4 = new Proj4Projection
        {
            InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326),
            ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(31466)
        };

        proj4.Open();

        var positionCurrentCoordinates = proj4.ConvertToInternalProjection(new PointShape(e.WorldCoordinate.X, e.WorldCoordinate.Y));
        var x = positionCurrentCoordinates.GetCenterPoint().X;
        var y = positionCurrentCoordinates.GetCenterPoint().Y;
        e.Result = string.Format("{0},{1}", x.ToString("N6"), y.ToString("N6"));
    }

Wish that’s helpful.

Regards,

Don

Hi Don,

what happens if i have a WMS-layer which has only “partial” data, means only data in a specific area. In your example you set the srid for the wmts-layer and not for the whole map. What do i do if i have a map without a wmts or wms-layer?

Regards,
Andreas

Hi Andreas,

For map, you can only need to set the MapUnit.

For layer, you should set the projection information, because maybe each layer have it’s own projection.

If you only have “partial” data, please find its bouding box and set current extent for make it render.

Regards,

Don