File tree Expand file tree Collapse file tree
main/java/org/geoscript/js/geom
test/resources/org/geoscript/js/tests/geoscript Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -301,6 +301,17 @@ public ScriptableObject densify(double tolerance) {
301301 return densified ;
302302 }
303303
304+ @ JSFunction
305+ public ScriptableObject randomPoints (int number ) {
306+ org .locationtech .jts .shape .random .RandomPointsBuilder builder = new org .locationtech .jts .shape .random .RandomPointsBuilder (factory );
307+ builder .setExtent (geometry );
308+ builder .setNumPoints (number );
309+ org .locationtech .jts .geom .Geometry geom = builder .getGeometry ();
310+ ScriptableObject points = GeometryWrapper .wrap (getParentScope (), geom );
311+ ((Geometry ) points ).projection = projection ;
312+ return points ;
313+ }
314+
304315 @ JSFunction
305316 public String getGeometryType () {
306317 return geometry .getGeometryType ();
Original file line number Diff line number Diff line change @@ -157,6 +157,15 @@ exports["test: create(bounds)"] = function() {
157157
158158} ;
159159
160+ exports [ "test: create random points" ] = function ( ) {
161+
162+ var geom = GEOM . Point ( [ 1 , 1 ] ) . buffer ( 10 )
163+ var points = geom . randomPoints ( 10 )
164+ ASSERT . ok ( points instanceof GEOM . MultiPoint )
165+ ASSERT . strictEqual ( points . components . length , 10 , "geometry has 10 components" ) ;
166+ }
167+
168+
160169exports [ "test: Point" ] = require ( "./geom/test_point" ) ;
161170exports [ "test: LineString" ] = require ( "./geom/test_linestring" ) ;
162171exports [ "test: Polygon" ] = require ( "./geom/test_polygon" ) ;
You can’t perform that action at this time.
0 commit comments