Giter Site home page Giter Site logo

Comments (7)

grimzy avatar grimzy commented on August 20, 2024 1

I'm working on a PR for this task srid.

from laravel-mysql-spatial.

grimzy avatar grimzy commented on August 20, 2024

Thank you for reporting this.

I agree, we have to handle SRIDs when fetching and comparing spatial data.
As you mentioned, to fix this issue we should update how all fields types are represented in queries, for example:

ST_GeomFromText("POINT(0 -10)")
ST_GeomFromText("POLYGON((40 -10,-10 -10,-10 40,40 40,40 -10))")

become:

ST_GeomFromText("POINT(0 -10)", 4326)
ST_GeomFromText("POLYGON((40 -10,-10 -10,-10 40,40 40,40 -10))", 4326)

(or an SRID different than 4326, depending on what is stored)

I think this issue is also related to #47 (how the package fetches the binary data from the database).

And yes, PRs are greatly appreciated! And unit tests to fasten a release event more! πŸ‘

from laravel-mysql-spatial.

kotasjan avatar kotasjan commented on August 20, 2024

So if I comprehended it well, there is currently no option how to save POINT object with SRID different than 0. Am I right? I was trying to find a way for a week without success. When I tried to use SRID = 0 all the spatial functions returned me really weird data so I assume it is caused by this. :(

from laravel-mysql-spatial.

sikhlana avatar sikhlana commented on August 20, 2024

@grimzy is there any update on adding support for SRID?

from laravel-mysql-spatial.

grimzy avatar grimzy commented on August 20, 2024

@sikhlana To be honest, no.

Currently we do this: https://github.com/grimzy/laravel-mysql-spatial/blob/master/src/Types/Geometry.php#L55:

public static function fromWKB($wkb)
    {
        // mysql adds 4 NUL bytes at the start of the binary
        $wkb = substr($wkb, 4);
        $parser = new Parser(new Factory());
        return $parser->parse($wkb);
    }

Literally: we remove the srid info from the WKB, then parse it. This code is to make the parser "compatible" with MySQL's WKB (meh... it just uses the default: 4326).

In any case, I've tried other parsers, tried to decode myself; but no dice.

Any help is greatly appreciated!!! Last time I pushed something for this was in the srid branch. I think the rest of the commits in that branch have every other change needed.

from laravel-mysql-spatial.

grimzy avatar grimzy commented on August 20, 2024

@kotasjn sorry :(

from laravel-mysql-spatial.

sikhlana avatar sikhlana commented on August 20, 2024

@grimzy I'm checking if integrating with https://github.com/libgeos/php-geos does any trick. Will let you know.

from laravel-mysql-spatial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.