Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

.net5.0, Removes the use of Newtonsoft.Json in favor of System.Text.J… #18

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

juliusfriedman
Copy link

.net5.0, Removes the use of Newtonsoft.Json in favor of System.Text.Json, it also removes the use of Tuples for (X,Y(Z)) Structures and instead uses System.Numerics.Vector which cuts down on the amount of reference parameters (register allocation) at the call site as well as increases performance for mathematical operations associated.

…son, it also removes the use of Tuples for (X,Y(Z)) Structures and instead uses System.Numerics.Vector which cuts down on the amount of reference parameters (register allocation) at the call site as well as increases performance for mathematical operations associated.
@juliusfriedman
Copy link
Author

This should be what you were looking for @xivk it also contains the work of @FObermaier

Copy link
Author

@juliusfriedman juliusfriedman left a comment

Choose a reason for hiding this comment

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

I think that Tile needs some work to use 3 backing vectors rather than transporting around 12 doubles, I think perhaps float should also be sufficient rather than double.

If that is okay then I would change TileMath to use MathF instead of Math as well as in a few other places (WebMercatorHandler)

See https://github.com/juliusfriedman/NetTopologySuite.IO.VectorTiles/tree/VectorizeTile for a branch which attempts this.

The only thing I noticed is that one of the unit tests failed with an off by 1 issue after changing to float.

The most immediate optimization I can think of in that branch would be to modify CalculateBounds and the Tile constructor to create the vectors only one time as right now they are created twice because I put Zoom in the wrong vector afg...

this.X = x;
this.Y = y;
this.Zoom = zoom;
_id = Tile.CalculateTileId(this.Zoom = zoom, this.X = x, this.Y = y);
Copy link
Author

Choose a reason for hiding this comment

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

TODO: Should be a single vector backing these

var n = Math.PI - ((2.0 * Math.PI * this.Y) / Math.Pow(2.0, this.Zoom));
this.Left = (double) ((this.X / Math.Pow(2.0, this.Zoom) * 360.0) - 180.0);
this.Top = (double) (180.0 / Math.PI * Math.Atan(Math.Sinh(n)));
var zoomSquare = Math.Pow(2.0, this.Zoom);
Copy link
Author

Choose a reason for hiding this comment

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

TODO: Should be a single vector backing these

this.Y.GetHashCode() ^
this.Zoom.GetHashCode();
}
public override int GetHashCode() => HashCode.Combine(X.GetHashCode(), Y.GetHashCode(), Zoom.GetHashCode());
Copy link
Author

Choose a reason for hiding this comment

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

Would be the individual backing vector hashcodes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant