14.01.2013 Views

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Measuring Distance<br />

Measuring distance in geographic or projected coordinate systems requires<br />

great circle calculations. Both MgGeometry::Buffer() and<br />

MgGeometry::Distance() accept a measurement parameter that defines the<br />

great circle to be used. If the measurement parameter is null, the calculation<br />

is done using a linear algorithm.<br />

Create the measurement parameter, an MgCoordinateSystemMeasure object,<br />

from the MgCoordinateSystem object.<br />

Distance is calculated in the units of the SRS. MgCoordinateSystem includes<br />

two methods, ConvertCoordinateSystemUnitsToMeters() and<br />

ConvertMetersToCoordinateSystemUnits() to convert to and from linear<br />

distances.<br />

For example, to calculate the distance between two MgGeometry objects $a and<br />

$b, using the coordinate system $srs, perform the following steps:<br />

$measure = new MgCoordinateSystemMeasure($srs);<br />

$distInMapUnits = $a->Distance($b, $measure);<br />

$distInMeters = $srs->ConvertCoordinateSystemUnitsToMeters(<br />

$distInMapUnits);<br />

Another way to calculate the distance is to use<br />

MgCoordinateSystemMeasure::GetDistance(), as in the following:<br />

$distInMapUnits = $measure->GetDistance($a, $b);<br />

Temporary Feature <strong>Source</strong>s<br />

Many geometric analysis operations require creating new features and new<br />

feature sources. For example, drawing a buffer around a point on a map requires<br />

a layer to display the buffer polygon, and the layer requires a feature source.<br />

To create a temporary feature source, perform the following steps:<br />

■ Create a feature class definition.<br />

■ Determine what properties you need to store for the features. Add the<br />

property definitions to the feature class definition.<br />

■ Create a feature schema containing the feature class definition.<br />

76 | Chapter 5 Analyzing Features

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!