[mapguide-users] RE: Wish List
    Kori Maleski 
    Kori.Maleski at websoftdev.com
       
    Tue Apr 10 18:41:02 EDT 2007
    
    
  
Here is how to get area with a coordinate transform:   
 
Say - if my map is projected, but my data is in Latlong.
 
 
 
            If l_ofeatures.ReadNext() Then
 
                Do
 
                    Dim l_oMgByteReader As MgByteReader =
l_ofeatures.GetGeometry("Geometry")
                    Dim l_oGeometryReaderWriter As New MgAgfReaderWriter
                    Dim l_oMgGeometry As MgGeometry =
l_oGeometryReaderWriter.Read(l_oMgByteReader)
                    Dim l_oMgPolygon As MgPolygon = l_oMgGeometry
 
 
                    'Get Current map projection
                    Dim l_sWKTproj As String = p_oMap.GetMapSRS()
                    'Create Coordinate System object to Reproject 
                    Dim l_oMGCoordinateSystemDestination As
MgCoordinateSystem = l_oMGCoordinateSystemFactory.Create(l_sWKTproj)
 
  Dim l_sWKTproj As String =
"GEOGCS[LL84,DATUM[WGS84,SPHEROID[WGS84,6378137.000,298.25722293]],PRIMEM[Gr
eenwich,0],UNIT[Degree,0.01745329251994]]"
                    Dim l_oMGCoordinateSystemSource As MgCoordinateSystem =
l_oMGCoordinateSystemFactory.Create(l_sWKTproj)
 
                    Dim l_oMGTransform As MgTransform
                    l_oMGTransform = New
MgCoordinateSystemTransform(l_oMGCoordinateSystemSource,
l_oMGCoordinateSystemDestination)
                    l_oMgPolygon.Transform(l_oMGTransform)
                    Dim l_dArea As Double = l_oMgPolygon.Area
 
                Loop While l_ofeatures.ReadNext()
 
            End If
 
            l_ofeatures.Close()
 
 
 
a'la PHP flavour:
 
 
function GetTransform()
      {
            $coordSysFactory = new MgCoordinateSystemFactory();
            $resourceService =
$this->site->CreateService(MgServiceType::ResourceService);
            
            $map = new MgMap();
            $map->Open($resourceService, $this->args['MAPNAME']);
            
$source =
$coordSysFactory->Create("GEOGCS[LL84,DATUM[WGS84,SPHEROID[WGS84,6378137.000
,298.25722293]],PRIMEM[Greenwich,0],UNIT[Degree,0.01745329251994]]");
            $target = $coordSysFactory->Create($map->GetMapSRS());      
            
      
            return new MgCoordinateSystemTransform($source, $target);
      }
 
 
 
 
________________________________
 
 
 
 
Kori Maleski
Senior Application Developer
WEBSOFT DEVELOPERS, INC.
P: (530) 759-8754 ext 114
F: (530) 759-0923
kori.maleski at websoftdev.com
________________________________
 
 
-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Jason Birch
Sent: Tuesday, April 10, 2007 2:24 PM
To: MapGuide Users Mail List
Subject: RE: [mapguide-users] RE: Wish List
 
Hi Jim,
 
That's giving you the area in degrees, which is a nonsense number.  
 
You need to transform your LL geometry into a projected system like UTM
(or maybe BC Albers for your application?).
 
Jason
 
-----Original Message-----
From: Jim O'Leary
Subject: [mapguide-users] RE: Wish List
 
However, the number that I get is:
 
0.00022107919307102
 
which does not seem meaningful.
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20070410/3a7fd8d4/attachment-0001.html
    
    
More information about the mapguide-users
mailing list