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
Parameter for line symbolizer to offset line to one side #180
Comments
|
[migurski] It would be awesome if text could be offset in this way too. I'm thinking about Andy Allan's hacks to get text-near-line working in OpenCycleMap. |
|
[springmeyer] pushing to 0.7.0 since it is an enhancement |
|
[ivansanchez] Isn't this the same as #71? |
|
[Ldp] A text-near-line hack? The other part of the request, offset placement, is interesting, but as said, I think largely the same as #71. |
|
[ivansanchez] No, this is not about text-near-line, it's about line-near-line. I think a LinePatternSymbolizer, with a 1-pixel-wide transparent image could serve as a hack for this, but offsetting the actual line vectors would be the desireable thing to have. In fact, the offset parameter would be ideally be applied to LinePatternSymbolizer too. And, as #71 says, you don't want to shift, you want to offset. And, by implementing offsets, you effectively solve #51 (just add two offset LineSymbolizers, one for each side of the line). |
|
[springmeyer] FYI: http://trac.osgeo.org/geos/ticket/215 and http://trac.osgeo.org/geos/changeset/2405 |
|
[springmeyer] I'm going to mark #71 a duplicate of this ticket and keep this one as it includes more details. There is a notion of re-joining lines from #71 that will need to be fleshed out more, as well as this nice graphic which should remain: [[BR]] |
|
[springmeyer] Replying to [comment:5 ivansanchez]:
Good points ivansanchez. I've marked those other tickets as duplicates of this one accordingly. #350 will remain as a proposal for a longer term, more sophisticated solution. |
|
[Ldp] Part of the needs of #335 could be solved with this. Lay down two offset strokes, and you have an unpainted core. It wouldn't work too cleanly with self-intersecting lines, but let's attack this one issue at a time! :) |
|
[Ldp] AIUI, in the current prototype, you need 2 LineSymbolizers to lay down a casing on both sides of a line. A possible shortcut would be to allow something like 10[[BR]] And internally it could create two symbolizers for that, one with +10 and another with -10 offset. |
|
[springmeyer] Patch attached implements line offsets for the LineSymbolizer by adding a 'stroke-offset' parameter. In XML: {{{ In Python:
Also includes tests that can be run with the existing nose suite:
or with nik2img.py:
ToDo Items include:
Thanks to Marcin and #332 for inspiration and ad example for solving this problem within |
|
[springmeyer] Two offsets without showing original (non-displaced) line - parallel effect [[BR]] Multiple, bundled line offsets of varying colors, width, and using dash_arrays 1 pixel displacement, 2 pixel wide lines in color ramp approximating cross-line gradient |
|
[springmeyer] blue is a negative -3 offset, and red is a postive +3 offset [[BR]] {{{ |
|
[migurski] YES! yes, yes, yes. Awesome. |
|
[springmeyer] The original implementation in python. Useful for testing new features: {{{ output = "/tmp/output2.svg" width, height = 600, 400 class Coord: class Segment: class Joint: def displace(c,angle,offset): def draw_offset_line(ctx, coords, offset, color=(0,0,0)): def draw_line(ctx, coords, color=(0,0,0)): def main(): main() |
|
[springmeyer] the single sided buffer has now landed in geos and been exposed in postgis trunk: http://trac.osgeo.org/postgis/ticket/413 So, this offers a means to test this patch against similar functionality that works in geographic space to offset lines. Thanks dfaubion for the new work. I've not had a chance to take a look yet, but will after things wrap up with the next release (0.7.1). Hopefully we can get this patch into trunk soon for more testing. I think one hold up is that we need to give though to how to support things such as offsets along with other methods that modify the geometry on the fly like the smoothing work in #332. It make not be possible to support them both on the same symbolizer, but ideally we could. |
|
[dpaleino] Is there any news on this ticket? :) I'm planning to do some offset-drawing in the near future, and I'm scared by the way to do this with current Mapnik ;-) |
|
[springmeyer] Hi David. It is on my list to get integrated into trunk, but the list is long :) You should be able to apply the 'mapnik0.7.1-offsets.patch' patch to mapnik 0.7.1 to try things out. It would be great to get your feedback on how the patch works. |
|
[djakk] Hello, I've noticed 3 bugs in the case "angle_joint" : {{{ }}} (sorry, I don't know how to create a patch …) |
|
[springmeyer] Thanks for the report! create a patch by checking out from svn and editing the file then doing: Or just by grabbing an original and doing: |
|
[djakk] I've managed to create a patch for mapnik 0.7.1 (it replaces the old one). I've fixed those bugs : Yet another bug is not solved : when a segment is too small compared to the offset, the offset line makes a loop Offset is not easy, look at this paper : http://cgcad.thss.tsinghua.edu.cn/~yongjh/papers/CiI2007V58N03P0240.pdf :O |
|
[djakk] My previous fix brings a new bug … so here comes a new patch ! This may be an other temporary offset patch, as the ultimate solution may come from an algorithm based on straight skeletons (http://en.wikipedia.org/wiki/Straight_skeleton) |
|
[springmeyer] djakk, thanks for the further work. I agree, I never saw how the 'sharp_spike_fix.patch' improve things, but rather just introduced bugs. I will take a look at your patch sometime in the next several weeks. |
|
[TobWen] djakk, thanks for your patch, but I'm not able to apply it to Mapnik 0.7.1, official release. I'm getting "hunk FAILED" several times. Are you applying it on the content of mapnik-0.7.1.tar.bz2 from BerliOS or some build from SVN? |
|
[TobWen] Replying to [comment:26 TobWen]: I've fixed it... wrong patch parameters (I've used p1 instead of p0) :-/ |
|
[Petr Dlouhy] Hello, I have improve the patch, so now it works also for LinePatternSymbolizer with attribute offset. |
|
[Petr Dlouhy] xificurk: are you sure, you have attached all the changes? The patch seems incomplete. |
|
[xificurk] Replying to [comment:30 Petr Dlouhy]:
Seems like some space monkeys got to the previous upload, thanks for notifying me. I've corrected the problem. |
|
so, there have been a few patch updates here since I last followed this ticket. Thanks for all the contributions and effort on this and sorry for abandoning (temporarily). So, I failed to post some work I did getting this working with mapnik 2.x. So, I am going to push that partial work now into trunk - the complex bit in ctrans.hpp - so that all other folks that have hacked at this can start working on the same code. But I'm not planning on enabling this feature until I have time to properly ensure this ctrans class can be chained with others. I will create another ticket for tracking (and explaining this). |
|
further work needed, which will be tracked starting with #927 |
…ne verticies - closes mapnik#180 - next task of exposing functionality refs mapnik#927
|
improved in #1269. |
An additional parameter for the line symbolizer, which would allow to shift a line asymmetrically to one side is currently missing.
It would allow some visualizations currently not possible: e.g. one side of a road could be painted in a color indicating a cycle way on that side, or several hiking routes with different colors could be rendered side by side instead of one route hiding the other.
The shift should be specifiable in pixels (to be able to make it consistent with line widths etc.), and maybe alternatively in map units (to paint a second line with a known constant distance to another one).
The difference to ticket http://trac.mapnik.org/ticket/51 would be, that the line would not be a border, but could have a larger distance or could overlap a main line, there could even be no main (unshifted) line, and it would allow asymmetric shifts (to only one side instead of always on both sides).
The text was updated successfully, but these errors were encountered: