I am trying to configure JSTS to load using ES6 modules so that I don't have to include the entire library.
There are minimal examples of how to do this online, including using an extend function to pull in functionality, however all attempts at getting the isValid method to work have failed:
import extend from 'jsts/extend';
import Geometry from 'jsts/org/locationtech/jts/geom/Geometry';
import Valid from 'jsts/org/locationtech/jts/operation/valid';
import WKTReader from 'jsts/org/locationtech/jts/io/WKTReader';
extend(Geometry.prototype, {
buffer: function () {
return Valid.isValid(this, ...arguments);
}
})
let reader = new WKTReader();
var geom = reader.read('POLYGON ((80 300, 280 300, 280 80, 80 80, 80 300), (260 280, 180 200, 100 280, 100 100, 260 100, 260 280))');
console.log(geom.isValid());
Each time all I am getting back is: Uncaught TypeError: geom.isValid is not a function
Example JSTS ES6 implementation: https://github.com/DenisCarriere/jsts-es6-example