TsGeo allow to format Polyline
class into GeoJSON output representation.
There are 2 ways to format output:
import {Coordinate} from "tsgeo/Coordinate";
import {Polyline} from "tsgeo/Polyline";
import {GeoJSON} from "tsgeo/Formatter/Polyline/GeoJSON";
/* Add the following in a method of TS class */
let polyline = new Polyline();
polyline.addPoint(new Coordinate(52.5, 13.5));
polyline.addPoint(new Coordinate(62.5, 14.5));
let formatter = new GeoJSON();
console.log(formatter.format(polyline));
This snippet display the following data:
{"type":"LineString","coordinates":[[13.5,52.5],[14.5,62.5]]}
import {Coordinate} from "tsgeo/Coordinate";
import {Polyline} from "tsgeo/Polyline";
import {GeoJSON} from "tsgeo/Formatter/Polyline/GeoJSON";
/* Add the following in a method of TS class */
let polyline = new Polyline();
polyline.addPoint(new Coordinate(52.5, 13.5));
polyline.addPoint(new Coordinate(62.5, 14.5));
console.log(polyline.format(new GeoJSON()));
This snippet display the following data:
{"type":"LineString","coordinates":[[13.5,52.5],[14.5,62.5]]}
Ajouter un commentaire