Skip to content

Postgis 2D support - #665

Merged
roji merged 1 commit into
npgsql:developfrom
rossini-t:postgis-support
Jul 30, 2015
Merged

roji merged 1 commit into
npgsql:developfrom
rossini-t:postgis-support

Conversation

@rossini-t

Copy link
Copy Markdown
Contributor

Just modified NpgsqlBuffer to handle NDR data structures.

@roji

roji commented Jul 14, 2015

Copy link
Copy Markdown
Member

That was pretty quick, thanks @rossini-t, thanks! I promise to review this ASAP.

@roji roji added feature and removed feature labels Jul 14, 2015
Comment thread src/Npgsql/NpgsqlBuffer.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do I understand correctly that PostGIS uses little endian everywhere? If so can you please rename the methods to ReadInt32LSB?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it more correct to check the byte specifying the byte order, or does PostGIS always do little endian?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One more note: these methods will break on a big endian system, can you please fix that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, for reading it will be easier this way.

@roji

roji commented Jul 15, 2015

Copy link
Copy Markdown
Member

@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.

Comment thread src/Npgsql/Npgsql.csproj Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should there actually be a dependency on System.Windows.Forms and on System.Drawing?

@roji

roji commented Jul 17, 2015

Copy link
Copy Markdown
Member

@rossini-t, once you're happy with everything please squash and rebase it, and let me know.

@roji

roji commented Jul 17, 2015

Copy link
Copy Markdown
Member

Since BBPoint is a struct, do the conversion to array result in the creation of copies and new memory allocations?

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.

@roji

roji commented Jul 17, 2015

Copy link
Copy Markdown
Member

@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 MinPgVersion attribute.

@rossini-t

Copy link
Copy Markdown
Contributor Author

Finally figured out how to rebase in a "clean" fashion.

@roji

roji commented Jul 29, 2015

Copy link
Copy Markdown
Member

@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?

@rossini-t

Copy link
Copy Markdown
Contributor Author

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.
But I will certainly implement those one day, for the sake of completion.

@rossini-t
rossini-t force-pushed the postgis-support branch 2 times, most recently from 3c5b885 to ff655e9 Compare July 30, 2015 12:14
@rossini-t

Copy link
Copy Markdown
Contributor Author

Here we are !

roji added a commit that referenced this pull request Jul 30, 2015
@roji
roji merged commit 0ebe6bc into npgsql:develop Jul 30, 2015
roji added a commit that referenced this pull request Jul 30, 2015
@roji

roji commented Jul 30, 2015

Copy link
Copy Markdown
Member

@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 :))

@rossini-t

Copy link
Copy Markdown
Contributor Author

No objection to the renaming. I apologize, I don't review myself enough !
Also, I would like to thank you for your attention and all the work you guys are doing !

@roji

roji commented Jul 30, 2015

Copy link
Copy Markdown
Member

Done.

Hope to see more contributions from you soon :)

@roji

roji commented Sep 7, 2015

Copy link
Copy Markdown
Member

@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?

@rossini-t

Copy link
Copy Markdown
Contributor Author

Yes, I think it could be a good thing to do.

@roji

roji commented Sep 8, 2015

Copy link
Copy Markdown
Member

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...

@roji roji added the feature label Apr 20, 2016
@roji roji added this to the 3.1 milestone Apr 20, 2016
@roji roji mentioned this pull request May 8, 2016
@suryapratap

Copy link
Copy Markdown

OGC GEOAPI conversion would have been nice to have

@roji

roji commented Oct 31, 2016

Copy link
Copy Markdown
Member

@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).

@suryapratap

Copy link
Copy Markdown

@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

@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?

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.

@roji

roji commented Nov 3, 2016

Copy link
Copy Markdown
Member

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.

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