bjornharrtell / jsts

JavaScript Topology Suite
http://bjornharrtell.github.io/jsts/
Other
1.49k stars 232 forks source link

Importing LengthIndexedLine and newing results in an error #521

Closed FreeFrags closed 5 months ago

FreeFrags commented 5 months ago

Hi,

Could some one please tell me why this works. (prebundled vs importing)

i have another example but then it is the other way around (when using OffsetCurveBuilder the prebundled doesnt work and the importing does)

Added to the index.html:

const parser = new jsts.io.OL3Parser();
    parser.inject(
        Point,
        LineString,
        LinearRing,
        Polygon,
        MultiPoint,
        MultiLineString,
        MultiPolygon,
        GeometryCollection
    );

    const jstsGeom = parser.read(lineString);
    // Create a LengthIndexedLine from the LineString
    const lengthIndexedLine = new jsts.linearref.LengthIndexedLine(jstsGeom);

And this doesnt resulting in the following error

Uncaught IllegalArgumentException: Lineal geometry is required
    at _LinearIterator.constructor_ (

Added to package.json "jsts": "^2.11.3"

import {LengthIndexedLine} from 'jsts/org/locationtech/jts/linearref';

const parser = new jsts.io.OL3Parser();
    parser.inject(
        Point,
        LineString,
        LinearRing,
        Polygon,
        MultiPoint,
        MultiLineString,
        MultiPolygon,
        GeometryCollection
    );

    const jstsGeom = parser.read(lineString);
    // Create a LengthIndexedLine from the LineString
    const lengthIndexedLine = new LengthIndexedLine(jstsGeom);