User Tools

Site Tools


map_suite_mvc_edition_projection_samples

Map Suite MVC Edition Projection Samples

Custom Parameters Projection

map_suite_wpf_desktop_edition_sample_custom_paramters_projection.jpg

In today’s Wpf project, we learn more about projection and how to handle a special case where the projection information in the PRJ file of a shapefile is not found as an EPSG or ESRI code in the spatial reference web site (www.spatial-reference.org). The strategy in this case is to build a proj4 string based on the parameters found in the PRJ file. Note that you must pay special attention to the false easting or northing parameters as they are always expressed in meters even if the projection is in another unit such as feet. For this example, we show how to convert from the local projection in Lambert Conformal Conic with regional specific parameters to Geodetic (WGS84) to match the World Map Kit.


Custom Rotation Projection

map_suite_wpf_desktop_edition_sample_custom_rotation_projection.jpg

In today’s project, we show how to create your own projection class that allows projecting a layer from any internal projection to any external while doing a rotation at the same time. Having the capability to apply those two operations in one step may come handy if the original layer was created in a different projection with the north at an angle and you want to align it on the base map. This is a Wpf project and you will need references to MapSuiteCore.dll and WpfDesktopEdition.dll to run it.


Distance Query on Projected Layers

In this sample, we learned how to use the method GetFeaturesWithDistanceOf when the data is projected. We just input the unit which is projected to, do not need to mind what the real unit is for the internal data before projection. It works fine with Map Suite Assemblies 4.5.54.0 or later.


Google Map to Geodetic

map_suite_wpf_desktop_edition_sample_googlemaptogeodetic.jpg

In today’s Wpf project, we are showing a trick for getting the current extent of the map with Google Map as an image and displaying it on a map in decimal degrees unit. You may be in a situation where you want the details and accuracy of Google Map, especially the satellite view but want to have it displayed on your map in decimal degrees. In this sample, you will see how to get the Google Map image and create the accompanying world file for decimal degrees. Notice that we are realizing an affine transformation on the image to go to Geodetic as illustrated in the case 3
http://en.wikipedia.org/wiki/World_file#Definition. You can also use this technique for any other background maps such as Bing Map, Open Street Map using Spherical Mercator.
Warning: It is possible to use a world file with parameters for a Geodetic system from an image originally in Spherical Mercator due to some similar projection characteristics. Applying the same operation for other projections such as Lambert or UTM will not work.


Graticule with Projection

map_suite_wpf_desktop_edition_sample_graticule_with_google_projection.jpg

In today’s Wpf project, we explore more features of GraticuleAdornmentLayer which shows meridians and parallels at various intervals based on the zoom level. Being natively in Geodetic, GraticuleAdornmentLayer can be set to any projection. In this project’s example, you have the graticule showing with World Map Kit in Spherical Mercator (Google Map projection). Also, not how easily you can change the appearance with properties such as GraticuleLineStyle and GraticuletextFont.


Local Datum UTM

map_suite_wpf_desktop_edition_sample_local_datum_utm.jpg

The purpose of this Wpf sample is to get familiar with the concept of datum and datum shift in UTM and Geographic coordinates. Using local data, you might be required to apply datum transformation to your data to go from an old datum to a more recent datum. Here we are taking the example of Australia which went to change its datum (from AGD84 to GDA94) for its mapping purposes. We show how to apply the datum transformation in both the longitude/latitude coordinate system and in the local UTM systems (AMG based on AGD84 and MGA based on GD94). See the code and read with attention the comments in the MouseMove event where all the projection logic is taken place. Notice that the correction is about 200 meters. Once you understand for the case of Australia, you will be able to apply the same principles for your own datums in UTM. For further reading:
http://www.cage.curtin.edu.au/~will/datum.html
http://www.usq.edu.au/course/material/SVY3107/lectures/Breeze/SVY2106amgmgafund/index.html


Projection by Analyzing Prj File

projectionreadingprjfile.jpg

This project demonstrates how to use the new ConvertPrjToProj4 function to dynamically project shapefiles based on the contents of their .prj file. This is one of the most requested new features of MapSuite 5.0. In the past, you were required to know the EPSG number or proj4 string in order to use the Proj4Projection class. The new ConvertPrjToProj4 method used in this sample will determine a shapefile's projection at runtime by analyzing the contents of the .prj file. This will enable the developer to build applications that allow users to dynamically add shapefiles with various projections and reproject them dynamically at runtime.


Note: There is also a ConvertProj4ToPrj function that can be used to build a .prj file from a proj4 string. This is not covered in this sample, but could be useful in the future.


Projection Distance LineStyle

map_suite_web_edition_sample_projection_distance_linestyle.jpg

This Web project is similar to the project “Distance Line Style”. Here we show how to use a projection of choice different from the projection used on the map. For example, you may have your map using Google map as a background. Google map uses Spherical Mercator projection which is not ideal for distance measurements, that is why using a more appropriate projection for distance measurement such as State Plane will give more accurate results. The CustomDistanceLineStyle inheriting from LIneStyle has the logic built in to have the distance calculated based on a projection of choice instead of the projection of the map.
As for the previous project “Distance Line Style”, you can see how the DrawCore function is overridden for the a specific need of style: displaying the distance label on each line segment making up a LineShape. In addition to the overriding of the DrawCore function, you will find useful some geometry functions such as GetPointOnLine to find the midpoint of a line segment and GetAngleFromTwoVertices to incline correctly the labels according to the orientation of each line segment. You will notice that the CustomDistanceLineStyle works for features made of LineShape and you will have to slightly modify to have it working with MultilineShape.


Wrap Dateline Mode With Projection

map_suite_wpf_desktop_edition_sample_wrap_date_line_mode_with_projection.jpg

In this Wpf project, we show a new property of Overlay, WrapDatelineMode. This property that allows to continuously pan west or east with world map was already available in the dev branch. This concept was shown in the previous sample “WrapDatelineMode”. Now it is fully supported in Map Suite 5 and you can see in this sample how the behavior for the map in both Decimal Degrees (Lat/Long) and Spherical Mercator (Google Map/Bing map projection). In order to run this sample, you will need the latest release for Wpf with references to MapSuiteCore.dll and WpfDesktopEdition.dll.


Datum Transformation

map_suite_services_edition_sample_datum_transformation.jpg

The purpose of today’s project is show how to handle the scenario where you have to apply a datum transformation to your data while keeping the same projection. This project addresses some confusion that might exist about the difference between datum and projection. We take a concrete example of a point in degrees using the ED50 datum and we apply a datum transformation so that it is in degrees using the WGS84 datum. Please, read carefully the comments to better grasp some key concepts.


Geodetic to State Plane

map_suite_services_edition_sample_geodetic_to_state_plane.jpg

Having to project a layer from geodetic (decimal degrees) to State Plane is a common task in GIS. One of the challenges is to know what State Plane zone a layer belongs to. This project is basically a little utility for State Plane projection needs. With the help of the State Plane zones layer provided, any layer in geodetic can be projected automatically to State Plane without having to do research to know the specific zone a layer belongs to. The opposite task (that comes even more frequently) of going from State Plane to Geodetic is unfortunately impossible to accomplish the same automatic way.


Geodetic to UTM on the fly

map_suite_services_edition_sample_geodetic_to_utm_on_the_fly.jpg

A common situation with dealing with geographic data from different sources is to have to “match” data in decimal degrees (Geodetic) with data in the local system of UTM. For example, you may have vector data in decimal degrees and an image in UTM. Projecting vector data is always more straightforward than projecting image data, that is why it is preferable to project the vector data to the image, rather than the opposite. In this project, we show the example of projecting a vector layer in decimal degrees (Geodetic) to UTM to “match” a tiff in that projection.


GeoRaster Projection

map_suite_services_edition_sample_raster_projection.jpg

This sample demonstrates how you can project raster layers in real-time for your .NET GIS application. In the sample it will show you show we switch a small sample image to and from a variety of projections. This sample was developer using the Map Suite Services Edition just to show how these feature are in the core of the framework. Projection can easily be applied to all of products such as the Wpf Desktop Edition, Silverlight Edition, MVC Edition and so on. It is important to note that this implementation is unmanaged and at the moment we do not have a managed version however we are working on it.


Great Circle on Pacific Rim

map_suite_services_edition_sample_great_circle_on_pacific_rim.jpg

This project extends what we learned in Pacific Rim. We show how to apply the Offset projection to Great Circle to have it displaying correctly over the pacific as opposed to Google Map where the same Great Circle is shown broken down.


Measurements Decimal Degrees

LEAD Technologies Inc. V1.01

This project is in response to a Discussion Forum post that has generated plenty of debate on the meaning of measuring area for shapes in decimal degrees.
In this project, you will see how to get area and length measurements according to the projection used from a shape in decimal degrees. For more information on why different measurements can be obtained from the same shapes, please read the Discussion Forum “GetArea on Buffered shape not working as expected”


Pacific Rim

picture_map_suite_samples_pacific_rim.jpg

This project shows how to display the Pacific Rim and Asia if you pan to the west, so that the world “wraps around,” as it does with Google Maps.\\Many of our Map Suite sample applications include an example of the world being displayed using a world ShapeFile. The ShapeFile is in Decimal Degrees and it displays the world according to longitude and latitude value ranges. These ranges are from -180 to 180 for longitude and 90 to -90 for latitude. In our various examples that use this ShapeFile, you see the Western Hemisphere on the left and the Eastern Hemisphere on the right. Now, a common request that we receive is to display the Pacific Rim and Asia if you pan to the west, so that the world “wraps around,” as it does with Google Maps. This can be accomplished in Map Suite 3.x by using a custom projection that offsets all of the points by 360 for the x (longitude) values. (180 + 180 360). …


Polygon across Meridian

map_suite_services_edition_sample_polygon_across_meridian.jpg

Following a request from the Discussion Forum on how to handle cases where the shape straddles the 180 degree meridian on a Decimal Degree map, we created this project. The solution is to split the shape into two main parts to be displayed on the two ends of the map.In this case, we use the case of a Polygon but this could easily be adapted for any other shapes such as lines.


Projection Distortion

map_suite_services_edition_sample_projection_distortion.jpg

Today’s project is more about learning and raising awareness about map projections than about a specific programming technique. By monitoring the Discussion Forum, we have encountered a large number of questions related to projections and distances. Many Map Suite users are unsettled by getting different distances from the same locations on various projections. To try to demystify this a little bit, we show how a regular grid on lat/long points get distorted in various ways depending on the projection applied. By visually seeing the distortion happening, it helps understand why distances can vary so wildly. You will also find some link to study this topic a little further if you wish.


Projection in Feet

no_screenshot.jpg

You may be in the situation where you have data in a projection that is in feet. For example, you may have the data for the USA in the standard Lambert projection in feet. Unfortunately, many of the projections offered in the PROJ4 library (the default projection library in Map Suite), handles the different projections in meters. It is the case for USA Contiguous Lambert Conformal Conic projection (ESPG code 102004). It is only available in meters.This project will show you the trick to easily have the projection of your choice being in feet using the original projection in meters.


Routing with Projections

map_suite_services_edition_sample_routing_with_projection.jpg

From a Discussion Forum request, in today’s project we show how to perform routing in one projection and display the result in another. You may be in the situation where you have your routable street data in State Plane meters and you have your base map in Geodetic (decimal degrees). This project shows you how to handle this case.


Save To Projection

LEAD Technologies Inc. V1.01

In the Projection section of the “How Do I” sample apps, there is a sample app that shows how to project on the fly a layer in one projection to another. While this is useful, you may be in the need to actually create a new layer in the desired projection. This project shows how to use the API SaveToProjection of ShapeFileFeatureLayer. In this project we use the example where you need your data in a regional projection saved to WGS84 (decimal degrees) to match other data such as GPS readings or the WorldMapKit.


Spherical Mercator Projection Adjustment

map_suite_desktop_edition_sample_spherical_mercator_projection_adjustment.jpg

The purpose of this sample is to address a projection issue that you may encounter when converting your data from your local projection to Google Map. It has been reported by Map Suite users that in some cases reprojecting their data to Google Map or other base maps using Spherical Mercator (Bing Map, Open Street Map etc) is inaccurate with the data being shifted a few hundreds of meters. This problem has been identified as being caused by an unnecessary grid shift when going from ellipsoid datum to spherical datum. Among other projections, the British National Grid (BNG) and the German Gauss-Kruger system have that problem when going to Spherical Mercator.
This sample uses the example of BNG to demonstrate the problem and how to fix it. The Map Suite development team will offer a permanent solution to this projection issue but in the meantime, as a rule of thumb, if your data shows some inaccuracies when going to Spherical Mercator, use the method you find this sample. This is a Desktop app but the concept shown applies to all editions of Map Suite.


Street Intersection

map_suite_services_edition_sample_street_intersection.jpg

From a request in the Discussion Forum, we decided to post a project today related to street intersection. In this project, we show how to get the intersection point of two streets. Basically, we get all the street features according to the street name and based on the shapes from those features, we do use some geometric function to determine what the intersection point of those two streets is. Keep in mind that the code provided in this sample app might not be the fastest or more optimized but it basically shows the algorithm for that purpose. This algorithm will be used to complement the Map Suite Geocoder product for Intersection geocoding.


World Coordinate with Rotation

In the “How Do I” sample apps, in the section “Projection”, you can find the sample “Use RotationProjection for a feature layer”. It allows to basically rotating the map to any angle. You can see how useful this can be by having the map rotated according to a vehicle direction, for example. Now, what is missing in this sample are the world coordinates in the status bar at the mouse move event. Today we show how to do that and what technique to use.


World Coordinates

LEAD Technologies Inc. V1.01

The purpose of this project is to complete the section “Screen & World Coordinates” of the “How Do I?” sample apps. You will learn how to display world coordinates at the mouse event. Notice that the Layer is in Mercator projection and we use a projection conversion to display Longitude and Latitude in addition to the world coordinates values in meters from the Mercator projection.
Also, we are reusing the DecimalDegrees static class we used in a previous project for formatting decimal degrees.

map_suite_mvc_edition_projection_samples.txt · Last modified: 2015/10/10 07:31 (external edit)