Giter Club home page Giter Club logo

geojson-polyline's People

Contributors

barberboy avatar esron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

geojson-polyline's Issues

Wrap LineString into proper GeoJSON

When I produce a LineString with your library, it's not a full GeoJSON

{fo_FvwwlQxQ|SbExEbBpJhCzc@FtRbSbZpAbBvAjCCEu@tEmB~CoWnKwl@bVq\\~N
becomes

{ type: 'LineString',
  coordinates: 
   [ [ -96.6286, 36.78334 ],
     [ -96.63195, 36.78033 ],
...
     [ -96.65802, 36.78504 ],
     [ -96.66058, 36.78977 ] ] }

Why is there no wrapper to produce a valid GeoJSON?

{
  "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": 
   [ [ -96.6286, 36.78334 ],
     [ -96.63195, 36.78033 ],
...
     [ -96.65802, 36.78504 ],
     [ -96.66058, 36.78977 ] ]
  },
  "properties": {}
}

I'm just curious, since every polyline js library I've tried out only outputs a GeoJSON fragment.

Weird encoded polyline

While encoding GeoJSON into encoded Polyline, I detected sometimes that the result is not what is expected.
Here is the GeoJSON:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [
            [
                -0.55461,
                47.497491
            ],
            [
                -0.554074,
                47.497393
            ],
            [
                -0.553654,
                47.497298
            ],
            [
                -0.553135,
                47.49717
            ],
            [
                -0.552639,
                47.497018
            ],
            [
                -0.552086,
                47.4968
            ]
        ]
      },
      "properties": {}
    }
  ]
}

And the encoded polyline:

iz{`HhikBRkBPsAXeB\\cBj@mB

Here is a screenshot of both GeoJSON and polyline on a map:
capture du 2018-08-08 11-59-51
It seems that a single point is wrong encoded (the fifth one) : [-0.552639,47.497018] is encoded as (47.49702,-0.55329)

Is there something wrong with the algorithm implementation?

Encode/Decode Multipolygon

I have tested this wonderful postgresql encoding function Google-Encoded-Polyline-PostGRESql-PostGIS-Implementation but there is a difference. In postgresql implementation he managed to output multipolygons as one string for example this one

cacoEbmxlNnI`FpJoe@xNsa@n[oGpCYfBMvASdOwCnAQbAE`A?bAFbAL~@T~@Z|@b@x@f@jAbAbAjAXb@q@FxDjErIjZxBdHpBnGbDbJpAhDjCtGdHnRsQlMvF~ORx@QrH{DnGcHrG{ArNnB`DoO~Lq@l@m@r@u`A}s@kJaDgIoC{J`LmAH_GsOaAwCyOV`BbB{@x@Sw@Ys@gEqJFEdCE`HCvDSyVyt@rVhK‡ywboEn{ylNrBIGkCqBFDlC

is a multipolygon with two polygons in it. In your implementation as far as I have seen, it splits multipolygons into polygons and decodes/encodes them as polyline/polygon. I was wondering in some way if I can decode it but I have no idea how to do that.

Uncaught TypeError: GeoJSONPolyline[method] is not a function

I'm using the library in a Vue.js project and in every action this function gets called.
Here is my code:

imgSrc() {
			if (!this.shape || !this.shape.features) return '/imgs/placeholder.jpg';

			const { coordinates: enc } = encode(this.shape.features[0].geometry);

			const width = 320;
			const height = 240;
			const fillColor = '0xFF000050';
			const color = '0xFF000080';
			const weight = 2;

			const url = `https://maps.googleapis.com/maps/api/staticmap?size=${width}x${height}&maptype=satellite&path=fillcolor:${fillColor}|color:${color}|weight:${weight}|enc:${enc}&key=MyAPIkey`;

			return encodeURI(url);
		},

My project is a SPA, therefore, I think the function gets called in every render of my components.

I'll open a merge request with the solution I came up with.

Support converting of Polyline to GeoJSON

Hey,

Maybe I missed something in the documentation, but is it possible to convert from Google Polyline Encoding to Geojson?

> echo "yvd|Fh~gqNfEqKzBEkEvKwB?" | geojson-polyline fromPolyline
internal/streams/legacy.js:59
      throw er; // Unhandled stream error in pipe.
      ^

Error: Invalid JSON (Unexpected "y" at position 0 in state STOP)
    at Parser.proto.charError (/usr/local/lib/node_modules/geojson-polyline/node_modules/jsonparse/jsonparse.js:90:16)
    at Parser.proto.write (/usr/local/lib/node_modules/geojson-polyline/node_modules/jsonparse/jsonparse.js:154:23)

Thanks!

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.