-
Notifications
You must be signed in to change notification settings - Fork 46
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
Improve geo encode #74
Conversation
Yes, please include benchmark script. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think it's fine that you removed the tolerance
and pending
globals. Those might have been used at some point, but don't think they are any longer.
I only noticed that some of the tests were now not run, but besides that LGTM 👍
I also think that checking in the benchmark script would be useful.
@@ -12,7 +12,7 @@ def test_suite(): | |||
except: | |||
import unittest | |||
|
|||
suite = unittest.TestLoader().discover("tests") | |||
suite = unittest.TestLoader().discover("tests", pattern='test_enc*.py') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to leave this in? I assume that it was just to speed up running the tests to exercise the geom encoding. If so, can we revert it back? The tests all pass for me locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that's a mistake. I've reverted.
properties = { | ||
'floatval': 3.14159 | ||
} | ||
self.assertRoundTrip( | ||
input_geometry=geometry, | ||
expected_geometry=[[-71, 42], [-71, 42], [-71, 42]], | ||
expected_geometry=[[-71, 42], [-71, 43], [-71, 42]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, good catch correcting these here.
No description provided. |
Here's the bench : https://gist.github.com/lexman/7042454fdaa1111f4efa05ef1d7c8f43 ! |
Thanks for sharing the benchmark script! All looks good to me, and my results were a little bit faster with your branch. @lexman is this at a good point to merge in? @zerebubuth any objections or thoughts? |
Please hold ! I've found a bug with linestrings when all MOVE_TO commands are too small (smaller than 1 pixel). I'm finishing a refactor to handle this case (with a test). Sorry for that. |
Sounds good. Nice catch! |
1 similar comment
At last :) I've refactored the previous code in order not to include in a tile any shape (linestring or polygon) that will be too small (ie less than one unit of the extent). In that case, neither the shape nor the attributes are added to the tile. Sorry for the delay. Here are the new perf results. Before :
After :
A bit more than 20 % on addFeatures |
Hello, just to mention that this pull request also brings improvements tovards V2 spec ( #42 ) by ensuring that a LineString geometry can't be only a moveto command and a polygon can't have less than 3 points... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a spurious print was left in, but otherwise looks good to me.
features = result['foo']['features'] | ||
import sys | ||
sys.stderr.write(str(features)) | ||
sys.stderr.write("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you meant to check in the print?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... Fixed !
1 similar comment
Thanks! |
Hi @lexman, I'm trying to use the change here to improve Mapzen's MVT tile performance and seem to be running into some dependency problems. When I try to generate an MVT tile I get the following exception: # $ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 python profile_tilequeue.py /etc/tilequeue/config.yaml
Traceback (most recent call last):
File "profile_tilequeue.py", line 3, in <module>
from tilequeue.command import lookup_formats
File "/usr/local/lib/python2.7/dist-packages/tilequeue/command.py", line 14, in <module>
from tilequeue.format import lookup_format_by_extension
File "/usr/local/lib/python2.7/dist-packages/tilequeue/format/__init__.py", line 3, in <module>
from tilequeue.format.mvt import encode as mvt_encode
File "/usr/local/lib/python2.7/dist-packages/tilequeue/format/mvt.py", line 1, in <module>
from mapbox_vector_tile.encoder import on_invalid_geometry_make_valid
File "/usr/local/lib/python2.7/dist-packages/mapbox_vector_tile/__init__.py", line 1, in <module>
from . import encoder
File "/usr/local/lib/python2.7/dist-packages/mapbox_vector_tile/encoder.py", line 14, in <module>
from .compat import PY3, vector_tile, apply_map
File "/usr/local/lib/python2.7/dist-packages/mapbox_vector_tile/compat.py", line 10, in <module>
from .Mapbox import vector_tile_pb2
File "/usr/local/lib/python2.7/dist-packages/mapbox_vector_tile/Mapbox/vector_tile_pb2.py", line 4, in <module>
from google.protobuf import descriptor as _descriptor
File "/usr/local/lib/python2.7/dist-packages/google/protobuf/descriptor.py", line 46, in <module>
from google.protobuf.pyext import _message
ImportError: cannot import name _message I'm running on Ubuntu 14.04.5 and have the protobuf 3.1.0 pip package installed: $ pip show protobuf
Name: protobuf
Version: 3.1.0.post1
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Author: protobuf@googlegroups.com
Author-email: protobuf@googlegroups.com
License: New BSD License
Location: /usr/local/lib/python2.7/dist-packages
Requires: six, setuptools Have you been able to get this running on Ubuntu? |
@iandees looks like this won't work for you exactly (python 2 vs 3), but for reference here's a known-working
|
Hello,
Here's a PR to improve the
_geo_encode()
function. It should improve_handle_skipped_last()
functionAfter the PR :
My major concern is that I've removed the
tolerance
logic, but according to the test suite, and test on our website everything is Ok. I don't know if anyone would changemapbox_vector_tile.encoder.tolerance
when using the library.I've also changed some tests because encoding a geometry with 3 same points [[-71, 42], [-71, 42], [-71, 42]] should not be valid. According to the spec this is not a valid geometry. I haven't done anything for this case, but I would suggest either to raise an exception or to omit the geometry. For the moment, the new encoder produces an invalid lienstring (without MOVETO comands)
If your need the benchmack script, I can provide it.