-
Notifications
You must be signed in to change notification settings - Fork 19
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
Various RAWR tile fixes #281
Conversation
… to tile coverage.
This can happen because we don't have perfect information about bi-directional linkages when building the index and, rather than index every element, the index is selective about what it stores. When the selection doesn't anticipate relation membership, it can result in a reference to a non-indexed element. At the moment, I don't think this is a problem, as those elements wouldn't have been "interesting" anyway.
…json seem to be unhappy with serialising a set.
…ls to geometry intersection.
tilequeue/query/common.py
Outdated
|
||
|
||
def parse_shape_types(inputs): | ||
lookup = { |
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.
Might be better to have this lookup
stored somewhere outside the function so it doesn't have to get re-created for every call of parse_shape_types()
. It might fit in as a @classmethod
on ShapeType
?
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.
We might be able to be even more clever by leaning on enums.
class ShapeType(Enum):
point = 1
line = 2
polygon = 3
multipoint = 1
linestring = 2
multilinestring = 2
polygon = 3
multipolygon = 3
Lookup is then just:
ShapeType[value.lower()]
which raises a KeyError
if not found.
Although the code as it is should work, I don't think this is a good idea since it can lead to some confusing behavior:
>>> ShapeType.multipolygon
<ShapeType.polygon: 3>
Anyway, just mentioning this but I like @iandees more. We could even just stick the lookup at global scope if the interaction with sticking it on enums is awkward.
tilequeue/query/common.py
Outdated
|
||
|
||
def parse_shape_types(inputs): | ||
lookup = { |
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.
We might be able to be even more clever by leaning on enums.
class ShapeType(Enum):
point = 1
line = 2
polygon = 3
multipoint = 1
linestring = 2
multilinestring = 2
polygon = 3
multipolygon = 3
Lookup is then just:
ShapeType[value.lower()]
which raises a KeyError
if not found.
Although the code as it is should work, I don't think this is a good idea since it can lead to some confusing behavior:
>>> ShapeType.multipolygon
<ShapeType.polygon: 3>
Anyway, just mentioning this but I like @iandees more. We could even just stick the lookup at global scope if the interaction with sticking it on enums is awkward.
This means that the lookup dictionary isn't being created for each call, and that the code is "adjacent" to the Enum it depends on, which hopefully makes it easier to understand.
ef38ef7
to
2cb637f
Compare
I ended up using the The alias method seems to work well, and I think it's quite readable. I put a comment in there to hopefully warn people away from using the aliases, and we'll have to see whether any other unexpected behaviour crops up as a result. Please let me know what you think. |
fetch=0, | ||
intersect=0, | ||
) | ||
return [], metrics, timing |
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.
Sorry! :(
Yea, this seems fine to me 👍 . I like that you put in a comment in there. |
Thanks! |
A slightly random grab-bag of changes that were necessary to get RAWR tiles rendering in a not-awful way.
LazyShape
, and use that to skip unnecessary calls to geometry intersection. This doesn't save as much time as I'd have hoped, but it seems like a relatively benign bit of code to leave in.ujson
seem to be unhappy with serialising a set. I think the version we're using in prod is okay, but I managed to randomly update mine locally while playing around with different Shapely versions.line
/linestring
usage. Move it all toEnum
-land instead.