Repository navigation
Postgis 2D support - #665
Conversation
|
That was pretty quick, thanks @rossini-t, thanks! I promise to review this ASAP. |
There was a problem hiding this comment.
Do I understand correctly that PostGIS uses little endian everywhere? If so can you please rename the methods to ReadInt32LSB?
There was a problem hiding this comment.
Is it more correct to check the byte specifying the byte order, or does PostGIS always do little endian?
There was a problem hiding this comment.
One more note: these methods will break on a big endian system, can you please fix that?
There was a problem hiding this comment.
I tought that the canonical default was little endian but I was wrong :
http://marc.info/?l=postgis-users&m=143701246423054&w=2
There was a problem hiding this comment.
So if I understand correctly you have to check the first byte to know whether the data is in MSB or LSB, and then call the appropriate method on NpgsqlBuffer, right?
If this is the case, we can add methods to NpgsqlBuffer which accept a parameter specifying MSB or LSB (e.g. a ByteOrder enum). The methods can internally do whatever is necessary, this way your handler will be less complicated...
There was a problem hiding this comment.
Yes, for reading it will be easier this way.
|
@rossini-t, this PR looks really great, thanks for the first-grade work on it. I've made some minor comments in the code, nothing serious. In addition, PostgisTypes.cs has an 8-char indent, can you please correct to 4? After that could please squash all the commits to one meaningful commit and rebase on develop (should be zero conflicts) and I'll merge it. |
There was a problem hiding this comment.
Should there actually be a dependency on System.Windows.Forms and on System.Drawing?
|
@rossini-t, once you're happy with everything please squash and rebase it, and let me know. |
I previously commented on the fact that there were only constructors with IEnumerable parameters; as you say this meant that it was impossible to create, say, a polygon without copying the array of its points. And if a point is a struct that includes copying the actual X and Y. However, now that there is a "zero-copy" constructor accepting an array (in addition to IEnumerable), that is no longer a problem: you can pass a single array (which is a reference type), no copying occurs whatsoever. |
|
@rossini-t, I've set up PostGIS on the build server so all your unit tests can run there. Note that there are currently failures on PG 9.0 and 9.1, here are the build results. My guess is that you're using some functions which aren't available on the older versions of PostGIS installed on those PG versions. If that's the case you can test for the PG version within your tests and modify the behavior, or even ignore them altogether on older databases with the |
97b6314 to
18c0f96
Compare
|
Finally figured out how to rebase in a "clean" fashion. |
|
@rossini-t, will give it another review later today, but it's great to see everything passing at the build server. The commit history still contains 4 commits, including a commit of mine... If you want to play around a little more with rebasing to clean this up go ahead, otherwise I'll do it when merging. Regardless, thanks for the super work! This is a first phase for 2D, right? I mean, you'll be submitting more work for 3D? |
|
Well I'll play a little more with rebase then :). We does'nt use the two others dimensions at work, so it does'nt itch too much. |
3c5b885 to
ff655e9
Compare
ff655e9 to
ecf5dff
Compare
|
Here we are ! |
|
@rossini-t, great! I've merged your PR, thanks for this great addition to Npgsql! I've added a few commits that do some cleanup and cosmetics, let me know if there's anything you object to. One last thing I came across during my cleanup: it seems we should rename the IGeometry base class to PostgisGeometry, because (1) it's not an interface, and (2) the convention is to have Postgis in the name. Do you have any objections? Thanks again for everything, I hope you'll have time to contribute 3D support by the time we release Npgsql 3.1 (don't worry, you have a long while :)) |
|
No objection to the renaming. I apologize, I don't review myself enough ! |
|
Done. Hope to see more contributions from you soon :) |
|
@rossini-t, do you know about this .NET geometry API? Is it relevant for PostGIS support, i.e. does it make sense for the Npgsql PostGIS types to extend those types? |
|
Yes, I think it could be a good thing to do. |
|
OK @rossini-t, have opened #774 for this. Feel free to work on it if you want, I'm not going to have the time in the near future... |
|
OGC GEOAPI conversion would have been nice to have |
|
@suryapratap what kind of support are you looking for? Note that it's already possible to read PostGIS objects as raw byte arrays, and then pass them to any third party library (such as GeoAPI) for parsing (same is true for writing). |
The comment was due to this post from @roji
My intent was to propose that extension of OGC GeoApi rather than MS Geometry/Geography makes more sense for PostGIS since OGC is the open standard in this case. |
|
OK, thanks for the clarification. Spatial type support is a high-priority issue in Entity Framework Core (dotnet/efcore#1100). I'm pretty sure they're in the process of designing it, while avoiding the mistakes of the EF DbGeography/DbGeometry types. The best thing to do at the moment is to wait and see where they take it. |
Just modified NpgsqlBuffer to handle NDR data structures.