1
import edu.umn.gis.mapscript.*;
4
* <p>Title: Mapscript shape dump example.</p>
5
* <p>Description: A Java based mapscript to dump information from a shapefile.</p>
6
* @author Yew K Choo (ykchoo@geozervice.com)
10
public class DumpShp {
11
public static String getShapeType(int type)
15
case 1: return "point";
17
case 5: return "polygon";
18
case 8: return "multipoint";
19
default: return "unknown";
23
public static void usage() {
24
System.err.println("Usage: DumpShp {shapefile.shp}");
28
public static void main(String[] args) {
29
if (args.length != 1) usage();
32
System.loadLibrary("mapscript");
34
catch(UnsatisfiedLinkError ule)
36
System.err.println(ule);
40
shapefileObj shapefile = new shapefileObj (args[0],-1);
41
System.out.println ("Shapefile opened (type = " + getShapeType(shapefile.getType()) +
42
" with " + shapefile.getNumshapes() + " shapes).");
45
shapeObj shape = new shapeObj(-1);
47
for(int i=0; i<shapefile.getNumshapes(); i++) {
48
shapefile.get(i, shape);
50
System.out.println("Shape[" + i + "] has " + shape.getNumlines() + " part(s)");
51
System.out.println("bounds (" + shape.getBounds().getMinx() + "," + shape.getBounds().getMiny() + ")" +
52
"(" + shape.getBounds().getMaxx() + "," + shape.getBounds().getMaxy() + ")");
54
for(int j=0; j<shape.getNumlines(); j++) {
55
lineObj part = shape.get(j);
56
System.out.println("Part[" +j + "] has " + part.getNumpoints() + " point(s)");
58
for(int k=0; k<part.getNumpoints(); k++) {
59
pointObj point = part.get(k);
60
System.out.println("Point[" + k + "] = " + point.getX() + ", " + point.getY());
65
// shapefile.delete();
66
// mapscript.msCleanup();
1
import edu.umn.gis.mapscript.*;
4
* <p>Title: Mapscript shape dump example.</p>
5
* <p>Description: A Java based mapscript to dump information from a shapefile.</p>
6
* @author Yew K Choo (ykchoo@geozervice.com)
10
public class DumpShp {
11
public static String getShapeType(int type)
15
case 1: return "point";
17
case 5: return "polygon";
18
case 8: return "multipoint";
19
default: return "unknown";
23
public static void usage() {
24
System.err.println("Usage: DumpShp {shapefile.shp}");
28
public static void main(String[] args) {
29
if (args.length != 1) usage();
32
System.loadLibrary("mapscript");
34
catch(UnsatisfiedLinkError ule)
36
System.err.println(ule);
40
shapefileObj shapefile = new shapefileObj (args[0],-1);
41
System.out.println ("Shapefile opened (type = " + getShapeType(shapefile.getType()) +
42
" with " + shapefile.getNumshapes() + " shapes).");
45
shapeObj shape = new shapeObj(-1);
47
for(int i=0; i<shapefile.getNumshapes(); i++) {
48
shapefile.get(i, shape);
50
System.out.println("Shape[" + i + "] has " + shape.getNumlines() + " part(s)");
51
System.out.println("bounds (" + shape.getBounds().getMinx() + "," + shape.getBounds().getMiny() + ")" +
52
"(" + shape.getBounds().getMaxx() + "," + shape.getBounds().getMaxy() + ")");
54
for(int j=0; j<shape.getNumlines(); j++) {
55
lineObj part = shape.get(j);
56
System.out.println("Part[" +j + "] has " + part.getNumpoints() + " point(s)");
58
for(int k=0; k<part.getNumpoints(); k++) {
59
pointObj point = part.get(k);
60
System.out.println("Point[" + k + "] = " + point.getX() + ", " + point.getY());
65
// shapefile.delete();
66
// mapscript.msCleanup();