Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //import com.vividsolutions.jts.geom.*;
- //import com.vividsolutions.jump.feature.*;
- //import com.vividsolutions.jump.task.*;
- //import com.vividsolutions.jump.workbench.*;
- MyClass() {
- int ize = 8;
- bar() { print("The '"+this.ize+"' is here!"); }
- return this;
- /*
- my = MyClass();
- print(my.ize);
- my.bar();
- */
- }
- {
- Random rand = new Random();
- randomString(int length) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0 ; i < length ; i++) sb.append((char)(64 + 27.0*Math.random()));
- return sb.toString();
- }
- schema = new FeatureSchema();
- schema.addAttribute("id",AttributeType.BIGINT);
- schema.addAttribute("name",AttributeType.STRING);
- schema.addAttribute("geometry",AttributeType.GEOMETRY);
- print("Attributes of schema:");
- for ( name : schema.attributeNames ) {
- print(" - "+name+" ["+schema.getAttributeType(name)+"]");
- }
- dataset = new FeatureDataset(schema);
- for (int i = 1 ; i < 6 ; i++) {
- coord = new Coordinate(rand.nextInt(100*i),rand.nextInt(100*i),rand.nextInt(100*i));
- geom = new GeometryFactory().createPoint(coord);
- geom.setSRID(23700);
- bf = new BasicFeature(schema);
- bf.setGeometry(geom);
- //bf.setUserData("id", rand.nextInt(100)); // don't work...
- //bf.setUserData("name", randomString(5)); // don't work...
- bf.setAttribute("id", rand.nextInt(1000));
- bf.setAttribute("name", randomString(8));
- dataset.add(bf);
- }
- print("Dataset size: "+dataset.size());
- for ( f : dataset.getFeatures() ) {
- print(" - "+f.getGeometry()+"\tid="+f.getAttribute(0)+"\tname="+f.getAttribute(1));
- }
- wc.layerManager.addLayer("DEMO","one point",dataset);
- print("˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙");
- geoms = new ArrayList();
- for (int i = 0; i < 5; i++) {
- double x = rand.nextInt(100); double y = rand.nextInt(100); double z = rand.nextInt(100);
- p = new Coordinate(x,y,z);
- pt = new GeometryFactory().createPoint(p);
- pt.setSRID(23700);
- //pt.setAttribute("id", rand.nextInt(100));
- //pt.setUserData("id", rand.nextInt(100));
- geoms.add(pt);
- }
- FeatureCollection points = FeatureDatasetFactory.createFromGeometry(geoms,schema);
- print("dataset size: "+points.size()+" [...]");
- wc.layerManager.addLayer("DEMO","more points",points);
- print("˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement