[mapserver-users] MapScript Projection Performance

Steve Lime sdlime at gmail.com
Wed Jun 8 08:50:31 PDT 2022


Hi all: I have a Perl script that runs against a shapefile to project a
geometry centroid from UTM to Lat/Lon. Code looks something like this:

my $proj_26915 = new mapscript::projectionObj('epsg:26915');
my $proj_4326 = new mapscript::projectionObj('epsg:4326');

while (my $shape = $layer->nextShape()) {
    my $point = $shape->getCentroid();
    $point->project($proj_26915, $proj_4326);
    # do something with $point
}

I get the following representative timings with ~250 polygon geometries in
the shapefile.

  MapServer 7.4 + Proj 6.2.1 = 0m0.180s
  MapServer 7.6 + Proj 6.2.1 = 0m7.000s
  MapServer 8.0 (main) + Proj 7.2.1 = 0m4.300s

Huge difference and things kinda become unusable. Things improve a bit with
newer versions but the performance hit is substantial. I thought at first
that it was the projection initialization that was taking all the time but
it's actually the "$point->project($proj_26915, $proj_4326);" statement.

Perhaps I'm doing something wrong?

--Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20220608/eeef4b07/attachment.htm>


More information about the MapServer-users mailing list