GithubHelp home page GithubHelp logo

gmgale / wtk-vector-geometry-reader-writer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 153 KB

๐ŸŒŽ Vector geometry objects <-> WKT converter.

TypeScript 93.76% JavaScript 6.24%
geometry-processing geospatial wkt

wtk-vector-geometry-reader-writer's Introduction

WTK Vector Geometry Reader/Writer

Helper classes to convert vector geometry objects to and from WKT.

Read more about WKT here.

The reader/writer classes can handle the most common geometry objects, including deeply nested geometry collection objects.

To run all tests:

npm i
npm run test

Reader

The reader takes a WKT string and returns a class/object/GeometryCollection(of nested classes/objects).
Example:

reader.read("POLYGON ((4, 6, 7, 10), (1, 2, 3, 7))");
reader.read("
  GEOMETRYCOLLECTION (POINT (4 6),
  LINESTRING (4 6, 7 10),
  MULTIPOLYGON (((4 6), (1 2)), (3 4)))");

Produces the classes/objects:

Polygon { values: [ [ 4, 6, 7, 10 ], [ 1, 2, 3, 7 ] ] }
GeometryCollection {
     values: [ [ [Point], [LineString], [MultiPolygon] ] ]
 }

Writer

The writer takes an instance of a Geometric class/object/GeometryCollection(of nested classes/objects) and returns a WKT formatted string.
Example:

writer.write(new Geo.MultiPoint([4, 6], [1, 2]));
writer.write(new Geo.GeometryCollection([
      new Geo.Point(),
      new Geo.LineString([3,4]),
      new Geo.MultiPolygon()
    ]));

Produces the WKT formatted strings:

"MULTIPOINT ((4, 6), (1, 2))"
"GEOMETRYCOLLECTION (POINT EMPTY, LINESTRING (3 4), MULTIPOLYGON EMPTY)"

Empty constructors

As seen in the above example, if the constructor for the Geometry class receives no arguments, 'EMPTY' will take it' place. The isEmpty() method can be called on any instance of a Geometry to check its values.

wtk-vector-geometry-reader-writer's People

Contributors

gmgale avatar

Watchers

 avatar

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.