Adding points to a shp file

mikiet mike.talbutt at DOTTEDEYES.COM
Tue Oct 10 11:39:54 EDT 2006


I've made some progress

the reason my shape file had 0 features after I ran my test was because it
was recreating the shape file, 

I changed the code from 

shapefileObj shapefile = new shapefileObj(shapeFullPath,
mapscript.MS_SHAPEFILE_POINT);

to

shapefileObj shapefile = new shapefileObj(shapeFullPath, -2);

and the shp file is not recreated, looking at the modified date it is
actuall modified, however when I run ogrinfo on my layer the feature count
has not gone up, also when I view the layer using OpenEV my new point has
not been added. Also still not seeing any error messages, can anyone help
please ?


Trimble, Beheen wrote:
> 
> Are you using a mapfile to display the point? Can you look at the new
> shape in arccatalog? Can you see the attribute of the point in its
> table?
>  
> 
> B
> 
> -----Original Message-----
> From: Mike Talbutt [mailto:mike.talbutt at dottedeyes.com] 
> Sent: Tuesday, October 10, 2006 9:03 AM
> To: Trimble, Beheen; MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: RE: [UMN_MAPSERVER-USERS] Adding points to a shp file
> 
> Unfortunately in the java mapscript API the add method on shape only
> takes a lineObj object, I believe a lineObj with only one point set is a
> point.
> 
> -----Original Message-----
> From: Trimble, Beheen [mailto:btrimble at sfwmd.gov] 
> Sent: 10 October 2006 13:57
> To: Mike Talbutt; MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: RE: [UMN_MAPSERVER-USERS] Adding points to a shp file
> 
> 
> I don't know mapscript but below does not look right to me:
> 
> lineObj lo = new lineObj();
> pointObj po = new pointObj(1d,1d,0d);
> lo.add(po);
> 
> Are you adding a point object to a line object consisting of only one
> point? If that is how line is created in java mapscript I think it
> should be 2 points. Try just adding the point to shape object by itself,
> just create on type shape object such as point shape.
> 
> B
> 
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
> Behalf Of mikiet
> Sent: Tuesday, October 10, 2006 8:48 AM
> To: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] Adding points to a shp file
> 
> I've noticed that the first time I ran my test it emptied the shape
> file, the original ogrinfo on the file produced was
> 
> Layer name: worldCities
> Geometry: Point
> Feature Count: 12686
> Extent: (-178.166667, -54.800000) - (179.383333, 78.933333) 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)
> 
> after I had run my test the features were 0 and the extents 0.
> 
> the point coordinate that I am adding (1,1) in the test is well within
> the extents of the original shape file  (-178.166667, -54.800000) -
> (179.383333,
> 78.933333)
> 
> 
> 
> 
> 
> Trimble, Beheen wrote:
>> 
>> What is the coordinate of your new points? Are you adding (1,1,0)? Is 
>> the unit understood by ogr? The problem usually is among extent, 
>> projection and spatial reference! See if mapscript has any of these 
>> types of functions. The extent shown, below, by grinfo is not
> promising.
>> 
>> 
>> B
>> 
>> -----Original Message-----
>> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]
> On
>> Behalf Of mikiet
>> Sent: Tuesday, October 10, 2006 7:14 AM
>> To: MAPSERVER-USERS at lists.umn.edu
>> Subject: [UMN_MAPSERVER-USERS] Adding points to a shp file
>> 
>> 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#a673434
>> 3
>> Sent from the Mapserver - User mailing list archive at Nabble.com.
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Adding-points-to-a-shp-file-tf2415928.html#a673566
> 4
> Sent from the Mapserver - User mailing list archive at Nabble.com.
> 
> 
> 
> Email has been scanned for viruses and spam by Altman Technologies'
> email management service - www.altman.co.uk/emailsystems
> 
> Email has been scanned for viruses and spam by Altman Technologies'
> email management service - www.altman.co.uk/emailsystems
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-points-to-a-shp-file-tf2415928.html#a6739118
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the mapserver-users mailing list