Opened 9 years ago

Closed 9 years ago

#1481 closed defect (fixed)

getselectedfeatures should use more efficient centroid processing

Reported by: jng Owned by: jng
Priority: high Milestone: 2.2
Component: AJAX Viewer Version: 2.2.0
Severity: major Keywords:
Cc: 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;

Attachments (3)

getselectedfeaturesaspx.patch (1.1 KB) - added by jng 9 years ago.
getselectedfeaturesjsp.patch (1.1 KB) - added by jng 9 years ago.
getselectedfeaturesphp.patch (1.2 KB) - added by jng 9 years ago.

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by jng

Changed 9 years ago by jng

Changed 9 years ago by jng

comment:1 Changed 9 years ago by jng

Priority: lowhigh

comment:2 Changed 9 years ago by jng

Resolution: fixed
Status: newclosed

Fixed in 2.2 (r5312) and trunk (r5314)

Note: See TracTickets for help on using tickets.