Adding points to a shp file

mikiet mike.talbutt at DOTTEDEYES.COM
Tue Oct 10 07:13:41 EDT 2006


Hi there, 

I am using java mapscript and have a requirement to add some points to an
ESRI shape file (bear with me here, I'm a mapinfo man). I'm using an ESRI
shape file that came with the ms101 tutorial WorldCities.shp. Its definitly
a point shape file as when I run ogrinfo on it I get 

Layer name: worldCities
Geometry: Point
Feature Count: 0
Extent: (0.000000, 0.000000) - (0.000000, 0.000000)
Layer SRS WKT:
(unknown)
ID: Integer (6.0)
ATTRIB: Integer (4.0)
MGCC: Integer (4.0)
ADMIN_CODE: Integer (4.0)
UFI: Integer (9.0)
POPULATION: Integer (9.0)
NAME: String (250.0)

I have created a simple class to add a point to this file, see below, the
code runs without error however no feature is added to the file, I'm sure
its a simple fix but can anyone point me in the right direction please ?

    public static void test(){
   	 try {
   		System.out.println("starting run....");
		shapeObj shape = new shapeObj(mapscript.MS_SHAPEFILE_POINT);
		lineObj lo = new lineObj();
		pointObj po = new pointObj(1d,1d,0d);
		lo.add(po);
		shape.add(lo);
		String shapeFullPath =
"C:\\ms4w\\apps\\ms101\\data\\shapefile\\WorldCities.shp";
		shapefileObj shapefile = new shapefileObj(shapeFullPath,
mapscript.MS_SHAPEFILE_POINT);
		shapefile.add(shape);
		System.out.println("Shape added");
    } catch (Exception e) {
    	e.printStackTrace();
    }
    }
-- 
View this message in context: http://www.nabble.com/Adding-points-to-a-shp-file-tf2415928.html#a6734343
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the mapserver-users mailing list