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

Add support for extended WKB encoding and PostGIS EWKB. #16

Open
gdey opened this issue Jun 12, 2018 · 11 comments
Open

Add support for extended WKB encoding and PostGIS EWKB. #16

gdey opened this issue Jun 12, 2018 · 11 comments
Labels

Comments

@gdey
Copy link
Member

gdey commented Jun 12, 2018

Here is postgis documentation on their extention to wkb to support ZM and srid values.
https://github.com/postgis/postgis/blob/2.1.0/doc/ZMSgeoms.txt

Wiki page on WKB with other consts.

https://en.wikipedia.org/wiki/Well-known_text#Well-known_binary

@gdey gdey added the question label Jun 12, 2018
@ARolek ARolek changed the title Add support for extended wkb encoding and Postgis ewkb. Add support for extended WKB encoding and PostGIS EWKB. Jul 19, 2018
@Hoovs
Copy link
Contributor

Hoovs commented Sep 12, 2018

@gdey @ARolek I am looking at this ticket but I am not 100% how to accomplish this / what this ticket success looks like.

If change the test case to be:

desc: Simple Point
expected: 1,2s 
bytes:{{
//01 02 03 04 05 06 07 08
  01                      // Byte order Marker little
  01 00 00 00             // Type 1 Point
  00 00 00 00 00 00 F0 3F // x 1
  00 00 00 00 00 00 00 40 // y 2
  00 00 00 00 00 00 F0 3F // z 1
}}

It does parse the Z if I made a [3]float type:
2018-09-11-213151_1366x768_scrot

So it seems like it is already clipping the Z cord because when I use the same test case as above with the unaltered code I get:
2018-09-11-213742_1366x768_scrot

It does leave the bytes on the reader because the data didn't fully use up the values but it "clips" them to the point that is need. I didn't try this for anything beyond point; can you point me to any examples of this

Also one of the big things of EWKB is that you can set SRID, is that needed for this?

Any help would be great. Thank you

@gbroccolo
Copy link
Collaborator

To include SRID you have to add 1 byte that encode the integer related to the SRID:

bytes:{{
//01 02 03 04 05 06 07 08
  01                      // Byte order Marker little
  01 00 00 00             // Type 1 Point
  00 00 10 E6             // <-- example for WGS84 (4326)
  00 00 00 00 00 00 F0 3F // x 1
  00 00 00 00 00 00 00 40 // y 2
  00 00 00 00 00 00 F0 3F // z 1
}}

@ARolek
Copy link
Member

ARolek commented Mar 16, 2020

@gbroccolo would you be interested in implementing this? I think it would be nice to have, especially when working with PostGIS.

@gbroccolo
Copy link
Collaborator

@ARolek I'm pretty new with Golang, more confident with PostGIS. I can try...

@ARolek
Copy link
Member

ARolek commented Mar 17, 2020

@gbroccolo your call, we're happy to help with code review if this is of interest to you. You could look at the wkb package for inspiration: https://github.com/go-spatial/geom/tree/master/encoding/wkb.

On another note, we're also looking to have native PostGIS geometry decoders if you're interested in tackling those.

@gbroccolo
Copy link
Collaborator

@ARolek I have one question here: do you think is it better to create a dedicated package for the extended wkb? I.e. something like geom/encoding/ewkb/? Or are you thinking to just extend the already existing methods?

@ARolek
Copy link
Member

ARolek commented Mar 24, 2020

@gbroccolo I would need to look at the wkb code again (@gdey authored most of that) but I think ideally we would have another package, ewkb which could leverage the wkb package. That way we don't have to make updates in two places if a bug is found in encoding/decoding geometries and such.

@gdey @ear7h any thoughts?

@gdey
Copy link
Member Author

gdey commented Mar 24, 2020

I need to look at the package. Give me a couple of days to look at it and get back to you.

@gdey
Copy link
Member Author

gdey commented Mar 31, 2020

@gbroccolo I think it makes to make a dedicated package. It looks like there isn't a way to tell wether the bin is an extended or not, from the type. You have to attempt the decode. So, the user will have to know. You may want to restructure some of the internal packages for better sharing, but overall I think a dedicated package makes sense.

@gbroccolo
Copy link
Collaborator

Hi @gdey, thanks for the feedback! Yeah, even in other frameworks generally wkb and ewkb are defined in dedicated modules/packages. I'll start creating a ewkb package, following more or less what is done in wkb. Maybe some refactor for shared utilities could be needed, indeed.

@gbroccolo
Copy link
Collaborator

@gdey @ARolek I added a comment related to this issue in go-spatial/tegola#449, just because I saw the two issues were related (maybe it was the wrong place).

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

No branches or pull requests

4 participants