You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a project I've been working on recently I've had need of the Geometry#apply function to convert the coordinates to and from WGS84, sinusoidal, and gnomonic projections.
I've had a lot of trouble getting this function to work correctly, but in the end I ended up using code similar to the following:
constjsts=require("jsts");consttranslateFilter={interfaces_: {indexOf: function(cls){// the class name here is minified! Unable to trust that it remains stable between releases.console.log(cls.name);returntrue;}},filter: function(coord){coord.x+=1;coord.y+=1;}};constcoords=[newjsts.geom.Coordinate(0,0),newjsts.geom.Coordinate(1,1)];constline=newjsts.geom.GeometryFactory().createLineString(coords);console.log(line.getEnvelopeInternal());line.apply(translateFilter);line.geometryChanged();console.log(line.getEnvelopeInternal());
This works ok if I want to just use CoordinateFilter, as its the first thing all the #apply implementations check for, but if I want to use a CoordinateSequenceFilter or GeometryFilter for example, I have to distinguish between them by their minified names.
It would be useful to have the *Filter classes exported in jsts.geom for this purpose, or to have a better interface for applying filters. If the *Filter classes do get exported, it would also be useful for their interfaces_ getter implementations to be filled out instead of being a blank array (see here). At that point the user could just subclass them and override #filter.
The text was updated successfully, but these errors were encountered:
In a project I've been working on recently I've had need of the
Geometry#apply
function to convert the coordinates to and from WGS84, sinusoidal, and gnomonic projections.I've had a lot of trouble getting this function to work correctly, but in the end I ended up using code similar to the following:
This works ok if I want to just use
CoordinateFilter
, as its the first thing all the#apply
implementations check for, but if I want to use aCoordinateSequenceFilter
orGeometryFilter
for example, I have to distinguish between them by their minified names.It would be useful to have the *Filter classes exported in jsts.geom for this purpose, or to have a better interface for applying filters. If the *Filter classes do get exported, it would also be useful for their
interfaces_
getter implementations to be filled out instead of being a blank array (see here). At that point the user could just subclass them and override#filter
.The text was updated successfully, but these errors were encountered: