Skip to content

Polygons will not load back from the database #1

Description

@adamboardman

I kept getting invalid geometry type for Polygon: 18580565393411 (0x10e620000003) until I did a fix similar to the one for linestring (Commit 948e081)

I went for this:

index fcfd9ac..d461f67 100644
--- a/polygon.go
+++ b/polygon.go
@@ -78,8 +78,9 @@ func (p *Polygon) Scan(val any) error {
                return err
        }
 
-       if wkbGeometryType != 3 {
-               return fmt.Errorf("invalid geometry type for Polygon: %d", wkbGeometryType)
+       geometryType := wkbGeometryType & 0x1FFFFFFF // Mask out SRID flag
+       if geometryType != 3 {
+               return fmt.Errorf("invalid masked geometry type for Polygon: %d", geometryType)
        }
 
        var numRings uint32

But I could imagine that the splitting it into two 32bit reads and checking the SRID might be a better way to go.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions