Ticket #156 (closed defect: fixed)

Opened 21 months ago

Last modified 20 months ago

Reprojection forced where not needed

Reported by: damiano Owned by: artem
Priority: normal Milestone: 0.6.0
Component: Core Library Version: 0.5.1
Severity: Normal Keywords: projection, renderer
Cc: rcoup Patch Needs Improvement: no
Needs Docmentation: no Has Patch?: no
Design Decision Needed: yes

Description

In a mapfile having a non standard projection, even if the map element and all the layer elements have the same srs, Mapnik reproject the map, increasing the rendering time.

HOW TO REPEAT:

Take a shapefile (a not so small one, about 200 MB would be good) with the default srs '+proj=latlong +datum=WGS84'. Run nik2img producing an image and check the total time needed to render.

Now project the same shapefile (for example, using ogr2ogr) and change the srs in the map and layers accordingly. Repeat the nik2img processing and you'll notice that the time is noticeably increased.

PROPOSED SOLUTIONS:

- Bypass the projection when the map and layer srs elements are the same (skipping it totally)

or

- Let mapnik know about the unit of the map and query the map accordingly.

Attachments

mapnik-skip-projection-if-equal.patch (1.3 kB) - added by jburgess777 21 months ago.
Patch to make reprojection a no-op if the source and dest are equal.

Change History

Changed 21 months ago by springmeyer

Damiano,

Thanks for the clear ticket. I can confirm what you describe, so it appears that mapnik is calling proj when it should not. I'm surprised about this shortfall and a fix to this should speed up a lot of folks rendering times.

The quick tests I wrote are available here for anyone that might want to run them while testing patches:

http://mapnik-utils.googlecode.com/svn/sandbox/proj_tests/

See the README.txt to know where to grab the data and run the test scripts.

Changed 21 months ago by jburgess777

Patch to make reprojection a no-op if the source and dest are equal.

Changed 21 months ago by springmeyer

  • cc rcoup added

Adding rcoup to the ticket so he'll see this ticket (since it related to his similiar nice fixes for input.postgis)

Changed 21 months ago by springmeyer

I've tested this patch.

I think it is ready to commit, give some thought about exposing a get/set method for bool is_source_equal_dest; in python.

Does that make sense?

Changed 21 months ago by damiano

Compiling the patched file give me this error:

src/proj_transform.cpp: In constructor ‘mapnik::proj_transform::proj_transform(const mapnik::projection&, const mapnik::projection&)’: src/proj_transform.cpp:43: error: no match for ‘operator==’ in ‘((mapnik::proj_transform*)this)->mapnik::proj_transform::source_ == ((mapnik::proj_transform*)this)->mapnik::proj_transform::dest_’

any idea?

Changed 21 months ago by rcoup

heh, i'm not sure whether just calling == would be clearer, but hey... ;)

damiano: you need the patch from #138 applied (or be running trunk >= r770) to get the == method on projections.

Changed 21 months ago by damiano

  • status changed from new to closed
  • resolution set to fixed

OK, patched from r776: fixed! Thank you folks!

Changed 21 months ago by springmeyer

  • status changed from closed to reopened
  • resolution fixed deleted

Great, Damiano, glad that works.

Thanks Robert for the assist.

I'd like to keep this ticket open however, until the patch is applied.

Thanks everyone.

Changed 21 months ago by artem

  • status changed from reopened to closed
  • resolution set to fixed

applied in r777

Changed 20 months ago by springmeyer

  • milestone set to 0.6.0
Note: See TracTickets for help on using tickets.