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
Reduce PostGIS vectors fetching #1136
Comments
I'm trying to figure out where to find the pixel size in geographical unite from the postgis datasource, and specifically in "featureset_ptr postgis_datasource::features(const query& q) const". Am I right that "query" doesn't contain this information ? If I have to compute it myself, how can I obtain the output image size ? |
NOTE: hard-coding the output image size shows me we can run with 0.22 the time it takes now, in certain conditions (1462892 vertices in 2183 geometries becoming 15789 vertices after reduction) |
sounds like some great progress. In IRC you ask about getting access to the image size. This is not directly accessible. It could be added, but right now instead the resolution is passed down in the query object (this is currently only used by the GDAL plugin for rasters). So, you should be able to use this in the postgis plugin: double pixel_size_x = 1.0 / boost::get<0>(q.resolution()));
double pixel_size_y = 1.0 / boost::get<1>(q.resolution())); |
Great, thank you. It indeed gives me the values I'd expect. |
You can find an experimental branch on git://github.com/strk/mapnik.git - branch features/pgis_vector_reduction I would feel better if the snap/simplify calls were decided by XML config file as I can think of cases in which the caller knows they would only add an overhead. What's the best practice for that ? |
Note that the features/pgis_vector_reduction branch is rooted at 2.0.x, not master |
NIce work! Being against 2.0.x for now is absolutely fine. Making this user configurable should also be fairly easy. Either the |
Uhm, !scale_denominator! could potentially be enough as long as I can use them in queries. I'm new to mapnik so starting with simple XML file (no subqueries in there) |
Now that I think about it !scale_denominator! is of no help, we do indeed need px_gx and px_gh, however we want to call them. Would surely need less thoughts as it's just enhancing what's passed around... The "simplify=true" idea is still nice as a quick way to do w/out thinking too much :) |
Passing user options can be done like: In XML: <Datasource>
<Parameter name="type">postgis</Parameter>
<Parameter name="simplify">true</Parameter>
</Datasource> The, in code, you can just do anywhere in the
|
Great, thanks. Parameter-based simplification pushed to my branch. I can reduce to a single commit if you want. The new commit drops the SnapToGrid call as well as it wasn't that interesting. |
For the record: it is , not and "true" should be "True" because "false" evaluates to true while "False" evaluates to false. Should I file another ticket or it's really intended to be hard to set to false and easy to set to true ? (I think anything would evaluate to true) |
Gah, I was wrong: "True" also evaluates to false ! |
woah? sounds like that might be a regression. |
I filed #1141 for the evaluation |
strk, for decimation (like you're doing here) ST_Simplify is really overkill - it's doing a lot more work than it needs to. Simplification for decimation can be simply a matter of traversing the coordinate lists and discarding all points within a given tolerance of the previous point. I'm thinking of adding this to JTS, since it's easy to implement. It might be nice if PostGIS had an ST_Decimate function, to see if that gave a further improvement in performance. |
On Fri, Mar 23, 2012 at 09:08:26AM -0700, Martin Davis wrote:
It would make very dense lines disappear (if every segment is shorter than
Anything in GEOS would incur in the geometry conversion cost. --strk; ,------o-. |
Well, you would never delete the start & end point of lines, so the worst that would happen is that lines would be reduced to a single line segment - which not a problem. If ST_Simplify is fast enough, that's fine. |
On Sun, Mar 25, 2012 at 08:48:56PM -0700, Martin Davis wrote:
The nice characteristic of DP simplification is that you know the max That said, it's always good to have more options so I'm not against having
I think it is --strk; |
@springmeyer ready to pull again. Let me know if you want me to rebase to 2.0.x |
uhm, while trying to port the code to 2.0.0-final I found another confusing bug in mapnik::optional. Here's the code:
And here's the output:
Puzzling, isn't it ? |
Alright, I see it's the same in 2.0.x branch. Uff... I'm fixing this, squashing the multi-commits into a single commit and re-creating the branch after rebasing to 2.0.x |
Alright 2.0.x-pgis_vector_reduction branch on my repository is now a single commit, rebased to 2.0.x and finally using the optional class in a correct way. |
interesting stuff, this can be a lot useful. would be cool if we can provide some performance tests for this. |
Hey @strk - not ignoring this, just traveling on vacation this week. I'd like to play around with this next week and do some perf tests locally before applying. Thanks for your patience. |
On Wed, Mar 28, 2012 at 07:43:49PM -0700, Dane Springmeyer wrote:
No problem. Note that the simplification only happens when the user The worst case you'll get is when no vertex is removed, which is --strk; ,------o-. |
@strk - a couple of thoughts on your comment about DP preserving the extent of geometries better than decimation.
|
On Thu, Mar 29, 2012 at 07:39:47AM -0700, Martin Davis wrote:
I mentioned preserving shape "look", not extent.
I probably don't have a clear definition of decimation. I guess it would be fine if you always compute "length" from Yes, should be faster than ST_Simplify. --strk; ,------o-. |
Yup, that's exactly how decimation works. Nice and simple - should be easy to implement. |
PostGIS vectors reduction, XML parameter driven (#1136)
We ca call this done. |
@mdavisog (a posteriori notice): your ST_Decimate suggestion could be implemented with http://trac.osgeo.org/postgis/ticket/1137#comment:2 |
It needs to be profiled but reducing the number of vertices fed to the renderer should speed things up. It's to be profiled to see if we'd be just moving the cost from one end to the other or if it is a general improvement to do so.
The text was updated successfully, but these errors were encountered: