New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support custom non-crs proj transforms with new proj api again #4309
base: master
Are you sure you want to change the base?
Conversation
a00817a
to
e9dc236
Compare
Codecov Report
@@ Coverage Diff @@
## master #4309 +/- ##
==========================================
- Coverage 75.04% 75.00% -0.04%
==========================================
Files 511 511
Lines 36546 36610 +64
==========================================
+ Hits 27425 27461 +36
- Misses 9121 9149 +28
Continue to review full report at Codecov.
|
I marked this pull request as "Draft" for two reasons:
So the basic I idea of this pull request to allow non-crs transforms already works well. Here is a rendering of the polygons for a tinshift transform: And here is a mapnik rendering with the map warped accordingly: The problem is, the gpx track doesn't get warped as well but isn't showing up at all. I'm using the python mapnik bindings with the commits from the tinshift = mapnik.Projection("+proj=pipeline +step +proj=webmerc +step +proj=tinshift +file=/tmp/tinshift.json")
m = mapnik.Map(600, int(600*height/width))
mapnik.load_map_from_string(m, open("mapnik.xml").read(), False, "/usr/share/openstreetmap-carto-common")
gpxstyle = mapnik.Style()
gpxrule = mapnik.Rule()
gpxsym = mapnik.LineSymbolizer()
gpxsym.stroke = mapnik.Color('blue')
gpxsym.stroke_width = 5
gpxsym.stroke_opacity = 0.5
gpxrule.symbols.append(gpxsym)
gpxstyle.rules.append(gpxrule)
m.append_style('GPXStyle', gpxstyle)
gpxlayer = mapnik.Layer('GPXLayer')
gpxlayer.datasource = mapnik.Ogr(file = sys.argv[1], layer = 'tracks')
gpxlayer.styles.append('GPXStyle')
m.layers.append(gpxlayer)
m.aspect_fix_mode = mapnik.aspect_fix_mode.GROW_BBOX
m.zoom_to_box(mapnik.Box2d(mapnik.Coord(0, 0), mapnik.Coord(width, height)))
m.srs = tinshift.params()
surface = cairo.SVGSurface("out.svg", 600, int(600*height/width))
mapnik.render(m, surface)
surface.finish() The same code renders the track just fine if I replace my
Those errors go away if I comment out the line |
7583a83
to
73c1ab1
Compare
73c1ab1
to
10801d4
Compare
@josch you can better view coverage here : https://app.codecov.io/gh/mapnik/mapnik/compare/4309/diff |
Thanks, I think I now added a test case that correctly executes the new code path. The only thing missing is the problem with correctly transforming my gpx layer. Any idea what could be wrong? |
I can't really answer this, but maybe @artemp could. |
Hi, I wanted to send another friendly ping. Any update on this? Thanks! |
Hi @josch, sorry I didn't have a chance to check your PR, yet. I made a reminder for Monday. Thanks for your patience. |
@josch - PR looks good, thanks. Could you share your GPX file and tinshift.json ? |
Sure, here you go: mapniktinshift.zip |
@josch I finally had a chance to test your import mapnik
tinshift = mapnik.Projection("+proj=pipeline +step +proj=webmerc +step +proj=tinshift +file=/tmp/tinshift.json")
wgs84 = mapnik.Projection("epsg:4326")
tr=mapnik.ProjTransform(wgs84, tinshift)
tr.forward(mapnik.Coord(9.974552, 49.789942))
(NOTE: I had to disable adding diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp
index fa141cf30..a54fe1a20 100644
--- a/src/proj_transform.cpp
+++ b/src/proj_transform.cpp
@@ -100,7 +100,7 @@ std::string pj_add_type_crs_if_needed(const std::string &str) {
if ((str.rfind("proj=", 0) == 0 || str.rfind("+proj=", 0) == 0 ||
str.rfind("+init=", 0) == 0 || str.rfind("+title=", 0) == 0) &&
str.find("type=crs") == std::string::npos) {
- ret += " +type=crs";
+ //ret += " +type=crs";
}
return ret;
} Without the patch above ^ I was getting invalid PROJ string error Omitting tinshift = mapnik.Projection("+proj=pipeline +step +proj=tinshift +file=/home/artem/projects/mapnik/bugs/4309/tinshift.json")
tr=mapnik.ProjTransform(wgs84, tinshift)
tr.forward(mapnik.Coord(9.974552, 49.789942))
Coord(6505465.205830257,286994.6673597563) works as in it produces some output. I don't really know much about |
No description provided.