-
Notifications
You must be signed in to change notification settings - Fork 15
Add possibility to convert tiles to other coordinates than WGS84 #34
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
Open
charlenni
wants to merge
12
commits into
NetTopologySuite:develop
Choose a base branch
from
charlenni:tgt
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e93a490
Add interface ITileGeometryTransform to project
charlenni ab44014
Add interface to definition of TileGeometryTransform
charlenni e958913
Replace all occurences of TileGeometryTransform with ITileGeometryTra…
charlenni c0e5bf4
Change interface to public
charlenni 113daae
Add parameter for function to create a new tile geometry transform
charlenni d297550
Rename tgs to tgt for consistency with writer
charlenni 9271cb3
Replace some strings for id with a constant
charlenni 847b1c8
Add a new tile geometry transformer which transforms from 0..4095 to …
charlenni e0f079c
Remove parameter because it wasn't possible to distinguish betwen fun…
charlenni 3e5e50c
Change values for _factor to double
charlenni 786cca9
Add tests for new tile geometry transform object
charlenni a2945ff
Change visibility for new tile geometry transformer to public, so tha…
charlenni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/NetTopologySuite.IO.VectorTiles.Mapbox/ITileGeometryTransform.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| using NetTopologySuite.Geometries; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| [assembly: InternalsVisibleTo("NetTopologySuite.IO.VectorTiles.Tests")] | ||
| namespace NetTopologySuite.IO.VectorTiles.Mapbox | ||
| { | ||
| /// <summary> | ||
| /// A transformation utility from WGS84 coordinates to a local tile coordinate system in pixel | ||
| /// </summary> | ||
| public interface ITileGeometryTransform | ||
| { | ||
| /// <summary> | ||
| /// The zoom level pixel resolution based on the extent. | ||
| /// </summary> | ||
| double ZoomResolution { get; } | ||
|
|
||
| /// <summary> | ||
| /// Transforms the coordinate at <paramref name="index"/> of <paramref name="sequence"/> to the tile coordinate system. | ||
| /// The return value is the position relative to the local point at (<paramref name="currentX"/>, <paramref name="currentY"/>). | ||
| /// </summary> | ||
| /// <param name="sequence">The input sequence</param> | ||
| /// <param name="index">The index of the coordinate to transform</param> | ||
| /// <param name="currentX">The current horizontal component of the cursor location. This value is updated.</param> | ||
| /// <param name="currentY">The current vertical component of the cursor location. This value is updated.</param> | ||
| /// <returns>The position relative to the local point at (<paramref name="currentX"/>, <paramref name="currentY"/>).</returns> | ||
| (int x, int y) Transform(CoordinateSequence sequence, int index, ref int currentX, ref int currentY); | ||
|
|
||
| /// <summary> | ||
| /// Transforms the point in the local tile pixel coordinates into WGS84 coordinates. | ||
| /// The return value is longitude and latitude of the tile pixel point (<paramref name="x"/>, <paramref name="y"/>). | ||
| /// </summary> | ||
| /// <param name="x">The horizontal component of the point in the tile coordinate system</param> | ||
| /// <param name="y">The vertical component of the point in the tile coordinate system</param> | ||
| /// <returns>WGS84 coordinates of the point in tile "pixel" coordinates (<paramref name="x"/>, <paramref name="y"/>).</returns> | ||
| (double longitude, double latitude) TransformInverse(int x, int y); | ||
|
|
||
| /// <summary> | ||
| /// Check if the point with tile coordinates (<paramref name="x"/>, <paramref name="y"/> lies inside tile extent | ||
| /// </summary> | ||
| /// <param name="x">Horizontal component of the point in the tile coordinate system</param> | ||
| /// <param name="y">Vertical component of the point in the tile coordinate system</param> | ||
| /// <returns>true if point lies inside tile extent</returns> | ||
| bool IsPointInExtent(int x, int y); | ||
|
|
||
| /// <summary> | ||
| /// Checks to see if a geometries envelope is greater than 1 square pixel in size for a specified zoom level. | ||
| /// </summary> | ||
| /// <param name="polygon">Polygon to test.</param> | ||
| /// <returns>true if the <paramref name="polygon"/> is greater than 1 pixel in the tile pixel coordinates</returns> | ||
| bool IsGreaterThanOnePixelOfTile(Geometry geometry); | ||
|
|
||
| (long x, long y) ExtentInPixel(Envelope env); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why did you choose to add an interface over making
TileGeometryTransforma public class that can be derived from?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 are right. That would be another viable way to do this. Would you prefer, that I write it in this way? Should be possible without problems.
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 am not sure if a class is the better approach. How much of it could be reused? @memsom could you set up a Transform for an arbitrary spatial reference system based on this PR?
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.
@FObermaier I haven't had time to dig in to the PR, but I believe this PR in general would help my use case. I don;t have a preference interface vs class, I mostly need to be able to plot the tiles in the co-ordinates system being used by the mapping engine's world view, and getting there directly without my current hack would help a lot.
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.
Ok, let's go one step back. All Mapbox vector tile coordinates are in the 4096x4096 raster. The tile has a size of 512x512. The NTS reader converts this coordinates to WGS84 (with negative y axis). It would be nice to have a function, that read the vector tiles data in its native coordinate system or can convert this coordinates in any coordinate system. For that you need a converter. This is the reason for this PR.
I hope, that explains the background. I fear, no one was looking in this part of the code since it was created.