Projection Sample

Created:12/21/2000
Last Modified:1/24/2002
Last Modified:1/25/2002
Description:

This sample demonstrates how to use the predefined factory SpatialReference coordinate systems. Four shape files, each based on a different coordinate system (with associated PRJ files), are displayed onto one common coordinate system. There are 5 MapControls - one main MapControl that displays the shapefiles onto the common coordinate system and four other smaller MapControls, each displaying a single shapefile in its specific coordinate system.

File NameDescriptionShapeTypePRJ type
europeEquidistantEast EuropePolygonTwo-Point Equidistant
westeuutm33West Europe PolygonUTM33N
citiesEuropean CitiesPointsWGS1984 geographicals
latlongLat/Lon linesLineStereographic

The user can draw a polygon (m_pPolygon) on the main map area and this polygon is then redrawn onto each of the smaller picture boxes in their relevant SpatialReference. The polygon is Densified before it is projected. The m_maximumSegmentPath for the Densify method is set depending on the coordinate system used.

A toolbar is used and a variable (m_activeControl) is used to manage which active tool was selected when used in the OnMouseDown event handler for the main Map control.

Finally, a SpatialReferenceFactory is used to create four global SpatialReference obects: m_pWGS1984, m_pEquidistant,m_pStereographic and m_pUTM33N.


How to use:
  1. The data used can be found in the ..\ArcObjects Developer Kit\Samples\Data\Projection folder. The shapefiles are loaded programmatically using the AddShapeFile method in the AddData procedure. You MUST edit this path to reflect the location of the sample data for your installation.
  2. Build the sample into Projection.exe.
  3. Run the executable. Click on the "DrawPolygon" tool in the Toolbar.
  4. Track a polygon on the main Map control. Double-click the mouse to finish. The polygon will be projected in the other smaller Map controls.
  5. To change the coordinate system for the main Map control, click on one of the radio buttons alongside the small Map controls.

Application:
MapControl

Minimum ArcGIS Version Required: 8.2

Difficulty: Beginner


Visual Basic
File Description
Splash.frm Visual Basic form for a splash screen.
projection.bmp Bitmap for the splash screen.
ProjectionSample.frm Visual Basic form that contains the Map controls used by the Projection Sample.
ProjectionSample.vbp Visual Basic project file for the Projection Sample.


Key CoClasses: MapControl, SpatialReferenceEnvironment
Key Interfaces: ISpatialReferenceFactory, ISpatialReferenceFactory, ISimpleFillSymbol, IPolygon
Key Members: Densify, Project, AddShapeFile, DrawShape, CreateGeographicCoordinateSystem, CreateProjectedCoordinateSystem