GithubHelp home page GithubHelp logo

convert wkb to wkt via php about geophp HOT 3 OPEN

sanabadai avatar sanabadai commented on August 21, 2024
convert wkb to wkt via php

from geophp.

Comments (3)

BathoryPeter avatar BathoryPeter commented on August 21, 2024

geoPHP::load($wkbString)->out('wkt');

But keep in mind, that geoPHP's WKB adapter is buggy and sometimes crashes. I had completely rewrite the WKB adapter in my fork supporting every OGC type and EWKB too. Give a try: https://github.com/funiq/geoPHP

from geophp.

sanabadai avatar sanabadai commented on August 21, 2024

i have this
require 'geoPHP.inc';
$dbString1='0xE61000000104060000004A5429C0E349424010806D3742964D4040038179E2494240BC8752993B964D407543AEF8E1494240BB1A3C373B964D40D29E7A81DF494240BDC654F23B964D409EE3FDE0E04942406CEB561143964D404A5429C0E349424010806D3742964D4001000000020000000001000000FFFFFFFF0000000003';
geoPHP::load($dbString1)->out('wkt');

but give me error:
Fatal error: Uncaught Error: Call to a member function out() on boolean in E:\xampp\htdocs\golbahar\test\test.php:4 Stack trace: #0 {main} thrown in E:\xampp\htdocs\golbahar\test\test.php on line 4

from geophp.

BathoryPeter avatar BathoryPeter commented on August 21, 2024

Because it is an invalid WKB.
At first, remove the unneeded 0x prefix, then we get a hex string.
Then look at the first byte: E6100000 = 4326 in decimal, so it is an EWKB and the geometry is in EPSG:4326. Its nice, but the first 10 bit (endianness and geometry type) is missing. From the EPSG code, we know that the string is little endian coded, and we can try to guess the type mask. For that, the have to investigate in the remaining part. Geometries are built from UInt32 and Double (64 bit) values, thus the remaining part must be divisible by 32. The string is 248 character which is 31 UInt32 value, hooray. Its too long to be a single point, so it must be some collection. Then the next UInt32 value (01040600) is the number of geometries. But if we convert 01040600 to decimal, we get a huge number: 394241. Its certainly bad.

At this point, we have to stop guessing. Your string is not a WKB and cannot be recover.

from geophp.

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.