Skip to content
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

Coordinates conversion #127

Merged
merged 4 commits into from
Jan 11, 2023
Merged

Coordinates conversion #127

merged 4 commits into from
Jan 11, 2023

Conversation

benoit9126
Copy link
Contributor

I have implemented in this PR:

@rmarianski This PR needs additional work. I would like to have your opinion on the coordinate conversion.

@coveralls
Copy link

coveralls commented Jan 3, 2023

Coverage Status

Coverage: 79.315% (+1.7%) from 77.612% when pulling 294a3d6 on benoit9126:issue107 into 2dfeb11 on tilezen:master.

Copy link
Member

@rmarianski rmarianski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the pr 🙇

I added a few comments for consideration

def decode(tile, y_coord_down=False):
vector_tile = decoder.TileData()
message = vector_tile.get_message(tile, y_coord_down)
def decode(tile, y_coord_down=False, crs_from=None, crs_to=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be nice to have this be a little bit more general, and just offer the ability to specify a transform fn: (Point -> Point). This could also mean that we wouldn't need to depend on pyproj, and could just add an example to the readme showing how it could be done.
(Don't mean to take the point -> point part literally, just have it take a (int,int) tuple or 2 parameters)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

mapbox_vector_tile/__init__.py Outdated Show resolved Hide resolved
pyproject.toml Outdated
pyclipper = "^1.3.0"
pyproj = "^3.4.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want to keep the pyproj dependency, it would be nice to relax this to being optional, with a run time check if it's used. Adding pyproj generally sounds heavy to me just to support this scenario. Even if you're on board with the transform fn idea as the specification parameter and we don't technically need pyproj, we might want to offer a convenience wrapper to facilitate the common pyproj usage. (If this doesn't make sense, I can make a pr or write the code out to help explain)

Seems like an extra would work here, right? Something like:

Suggested change
pyproj = "^3.4.1"
pyproj = { version = "^3.4.1", optional = true }
[tool.poetry.extras]
proj = ["pyproj"]

Regardless, can we add a note to the readme for this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will apply this. 👍

geometry = self.parse_geometry(feature.geometry, feature.type, layer.extent, y_coord_down)
new_feature = {"geometry": geometry, "properties": props, "id": feature.id, "type": feature.type}
geometry = self.parse_geometry(geom=feature.geometry, ftype=feature.type, extent=layer.extent)
new_feature = {"geometry": geometry, "properties": props, "id": feature.id, "type": "Feature"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we grow an option that would keep the previous behavior? My guess would be that it's not practically being checked anywhere, but this would be insurance if it were.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

geometry = self.parse_geometry(feature.geometry, feature.type, layer.extent, y_coord_down)
new_feature = {"geometry": geometry, "properties": props, "id": feature.id, "type": feature.type}
geometry = self.parse_geometry(geom=feature.geometry, ftype=feature.type, extent=layer.extent)
new_feature = {"geometry": geometry, "properties": props, "id": feature.id, "type": "Feature"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tangentially, we might want to also collect a list of the user facing changes and document them in the readme under an upgrading section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. I would like first to stabilize the interface before writing the documentation.

@benoit9126
Copy link
Contributor Author

benoit9126 commented Jan 6, 2023

@rmarianski I will add tests and example in the README after you validate the main idea of options/default_options strategies.

Copy link
Member

@rmarianski rmarianski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me 🙇 I put in a minor comment to suggest a possible new name for the layer specific options, let me know what you think.

Comment on lines 4 to 11
def decode(tile, options=None, default_options=None):
vector_tile = decoder.TileData(pbf_data=tile, options=options, default_options=default_options)
message = vector_tile.get_message()
return message


def encode(
layers,
quantize_bounds=None,
y_coord_down=False,
extents=4096,
on_invalid_geometry=None,
check_winding_order=True,
):
vector_tile = encoder.VectorTile(extents, on_invalid_geometry, check_winding_order=check_winding_order)
def encode(layers, options=None, default_options=None):
vector_tile = encoder.VectorTile(default_options=default_options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we be more explicit and call it layer_options and default_options? Or per_layer_options?

Also, since we've hoisted the options all under a top level key, what do you think of adding detailed docstrings for the encode/decode functions, and enumerating all options and explaining how they work? I expect that having all the specifics listed out here would go a long way towards making it easy for others to use. Happy to just leave this off for a separate pr though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please read the documentation I wrote? I am not a native English speaker, so you may find some mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great to me, thanks!

@benoit9126 benoit9126 marked this pull request as ready for review January 10, 2023 08:55
@rmarianski rmarianski merged commit f4ef1b0 into tilezen:master Jan 11, 2023
@benoit9126 benoit9126 deleted the issue107 branch January 12, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants