File: ShapeInfo.java

package info (click to toggle)
mapserver 6.0.1-3.2%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 17,940 kB
  • sloc: ansic: 209,190; cpp: 53,949; cs: 12,101; python: 5,323; perl: 3,332; makefile: 841; lex: 706; yacc: 609; java: 466; xml: 379; sh: 253; tcl: 158; ruby: 53
file content (45 lines) | stat: -rw-r--r-- 1,345 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import edu.umn.gis.mapscript.*;

/**
 * <p>Title: Mapscript shapeinfo example.</p>
 * <p>Description: A Java based mapscript example to dump information from a shapefile.</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: GeoZervice</p>
 * @author Yew K Choo (ykchoo@geozervice.com)
 * @version 1.0
 */

public class ShapeInfo {
  public  static String getShapeType(int type)
  {
    switch (type)
    {
      case 1: return "point";
      case 3: return "arc";
      case 5: return "polygon";
      case 8: return "multipoint";
      default: return "unknown";
    }
  }

  public static void usage() {
    System.err.println("Usage: ShapeInfo {shapefile.shp} {shapefile.dbf}");
    System.exit(-1);
  }

  public static void main(String[] args) {

    if (args.length != 2) usage();

    shapefileObj shapefile = new shapefileObj (args[0],-1);

    System.out.println ("Shapefile name = " + args[0]);
    System.out.println ("Type = "  + getShapeType(shapefile.getType()));
    System.out.println ("Number of features " + shapefile.getNumshapes());
    System.out.println("bounds (" + shapefile.getBounds().getMinx() + "," + shapefile.getBounds().getMiny() + ")" +
                        "(" + shapefile.getBounds().getMaxx() + "," + shapefile.getBounds().getMaxy() + ")");
    shapefile.delete();
    //mapscript.msCleanup();
  }

}