[mapguide-trac] #1481: getselectedfeatures should use more efficient centroid processing

MapGuide Open Source trac_mapguide at osgeo.org
Wed Oct 20 23:07:10 EDT 2010


#1481: getselectedfeatures should use more efficient centroid processing
---------------------------+------------------------------------------------
   Reporter:  jng          |       Owner:  jng  
       Type:  defect       |      Status:  new  
   Priority:  low          |   Milestone:  2.2  
  Component:  AJAX Viewer  |     Version:  2.2.0
   Severity:  major        |    Keywords:       
External_id:               |  
---------------------------+------------------------------------------------
 The current getselectedfeatures.aspx/php/jsp uses MgGeometry.GetCentroid()
 to calculate the zoom location.

 It turns out GetCentroid() does a full scan of the geometry's WKT.

 For geometries with an absurd amount of vertices, this is a woefully
 inefficient method of calculating the centroid.

 Since the purpose of this centroid is to be the zoom location, we don't
 exactly require a *precise* zoom location. Something approximate should
 suffice. So the centroid processing should change from this:

 {{{
 MgCoordinate pt = geom.Centroid.Coordinate
 zoom.X = pt.X;
 zoom.Y = pt.Y;
 }}}
 to this:
 {{{
 MgEnvelope env = geom.Envelope();
 MgCoordinate ll = env.GetLowerLeftCoordinate();
 MgCoordinate ur = env.GetUpperRightCoordinate();
 zoom.X = (ur.X + ll.X) / 2;
 zoom.Y = (ur.Y + ll.Y) / 2;
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/1481>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list