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

Potential Polygon Bug? #15

Open
AlextheYounga opened this issue Feb 28, 2020 · 0 comments
Open

Potential Polygon Bug? #15

AlextheYounga opened this issue Feb 28, 2020 · 0 comments

Comments

@AlextheYounga
Copy link

AlextheYounga commented Feb 28, 2020

I'm trying to test if a point is inside a polygon and I'm wondering if I have found an issue or perhaps I've misread the docs. Would really appreciate your help here. I included a couple of dump and die's to show that my code appears to be correct. Thanks ahead of time.

     use Geokit\Polygon;
     use Geokit\Position;

    $polygon = new Polygon(
            new Position(125.2, 5512),
            new Position(136.6, 5512),
            new Position(139.7, 3880),
            new Position(139.7, 3307),
            new Position(129.9, 3307),
            new Position(122, 4409),
        );
        $envelope = $polygon->close();
     dd($polygon);
     //Output
        array:7 [
        0 => Geokit\Position^ {#36
            -x: 125.2
            -y: 5512.0
        }
        1 => Geokit\Position^ {#1282
            -x: 136.6
            -y: 5512.0
        }
        2 => Geokit\Position^ {#1289
            -x: 139.7
            -y: 3880.0
        }
        3 => Geokit\Position^ {#1290
            -x: 139.7
            -y: 3307.0
        }
        4 => Geokit\Position^ {#1291
            -x: 129.9
            -y: 3307.0
        }
        5 => Geokit\Position^ {#1292
            -x: 122.0
            -y: 4409.0
        }
        6 => Geokit\Position^ {#1293
            -x: 125.2
            -y: 5512.0
        }
        ]

    $point =  new Position(125.98652772609, 5374.0);
     dd($point)
    //Output
     Geokit\Position^ {#1295
       -x: 125.98652772609
       -y: 5374.0
     }
     //This point should appear inside the $envelope.
     //I've tested this in Excel as well 
     //as a Javascript geometric package to make sure.

     $envelope->contains($point);
     //false
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

No branches or pull requests

1 participant