import processing.opengl.*; import org.gdal.ogr.*; import org.gdal.gdal.*; import java.util.*; float xmin,xmax,ymin,ymax; int redval = 0; DataSource src; Layer lyr; ArrayList ftrlist; //contains all our features/suburbs PGraphics buffer; //backbuffer which allows for picking! //suburb[] suburbs; //suburbs vector to hold the mapped vertices LinkedList[] mygeoms; void setup() { size(600,600,OPENGL);//P3D); background(127); frameRate(30); // // buffer is created using applet dimensions // buffer = createGraphics(width, height, P3D); // Let the user select a Shapefile String loadPath = selectInput(); if(loadPath == null) { println("No file was selected!"); exit(); return; } println(loadPath); String[] arr = { "--debug", "on" }; ogr.GeneralCmdLineProcessor(arr); ogr.RegisterAll(); print("No. of available drivers : "); println(ogr.GetDriverCount()); src = ogr.Open(loadPath); if(src == null) { println("unable to open!!=="); println(gdal.GetLastErrorMsg()); println("=="); return; } System.out.printf(":::: %s information ::::\n", (new File(loadPath)).getName()); System.out.printf("No. of Layers : %d\n", src.GetLayerCount()); double[] extents; for(int l=0; l(lyr.GetFeatureCount()); for(int f=0; f li = mygeoms[f].listIterator(); // mygeoms[f].get(0).draw(this.g); fill(246,46,78); int ll = 0; while(li.hasNext()) { PFeature tmpf = li.next(); // System.out.printf(" geometry %d -> ", ll); // System.out.printf("%d points\n", (tmpf.closed ? tmpf.npts+1 : tmpf.npts)); tmpf.draw(this.g); // li.next().draw(this.g); ll++; } //draw the BBs for the features noFill(); double[] extents = new double[4]; Geometry ftrgeom = lyr.GetFeature(f).GetGeometryRef(); ftrgeom.GetEnvelope(extents); // System.out.printf(" %f %f %f %f\n", extents[0], extents[1], extents[2], extents[3]); float x1,y1,x2,y2; x1 = map((float)extents[0],xmin,xmax,0.0,width-1.0); x2 = map((float)extents[1],xmin,xmax,0.0,width-1.0); y1 = map((float)extents[2],ymin,ymax,0.0,height-1.0); y2 = map((float)extents[3],ymin,ymax,0.0,height-1.0); stroke(127,127,255); fill(127,127,255,50); rectMode(CORNERS); rect(x1,y1,x2,y2); } } void processFeature(Geometry ftrgeom, int f) { PFeature pf = null; Geometry g; System.out.printf(" %s::", ftrgeom.GetGeometryName()); switch(ftrgeom.GetGeometryType()) { case ogr.wkbUnknown: case ogr.wkbNone: System.out.printf(" Unknown/None geometry type found!!\n"); break; case ogr.wkbPoint: case ogr.wkbPoint25D: System.out.printf(" Point/Point25D geometry; ignoring!!\n"); break; case ogr.wkbLineString: case ogr.wkbLineString25D: System.out.printf(" LineString found. Dumping now...\n"); System.out.printf(" %d points\n", ftrgeom.GetPointCount()); pf = new PFeature(ftrgeom.GetPointCount()); for(int i=0; i %d points\n", r, ftrgeom.GetGeometryRef(r).GetPointCount()); g = ftrgeom.GetGeometryRef(r); //last pt is the same as first, better to let processing complete //the polygon. otherwise polygon might appear unclosed! pf = new PFeature(g.GetPointCount()-1); for(int i=0; i found. Info...\n"); // System.out.printf(" %d geometries\n",ftrgeom.GetGeometryCount()); System.out.printf(" %d geometries:\n",ftrgeom.GetGeometryCount()); for(int ig=0; ig