Hi Sass,
Here's a class I'm working on that might help out. You would change
the thinData class to do something else with your list, like add
/modify the feature you want.
I would note that this class screws up shape files with shapes that
have boundaries with each other, which is why I haven't put in the
toolkit. But, it does show how to read/write shape files with the
com.bbn.openmap.dataAccess.shape package components.
Not having a dbf file shouldn't make a difference.
Hope this helps,
Don
On Mar 26, 2004, at 12:03 PM, Sass Bálint wrote:
> Hi,
>
> I'm a newbie and my question is how to modify a Shapefile.
> I mean e. g. add a new polygon or move one point of a polygon.
>
> I think I can read and write shapefiles in the following way,
> but what to do with the EsriGraphicList object ?
>
> I simply want draw the Hungarian lake 'Balaton'
> onto the 'dcwpo-browse' map.
>
> Does it couse problem that I don't have any .dbf file for this .shp
> file ?
>
> -----
>
> import java.io.*;
> import java.util.*;
>
> import com.bbn.openmap.omGraphics.*;
> import com.bbn.openmap.plugin.*;
> import com.bbn.openmap.plugin.esri.*;
> import com.bbn.openmap.dataAccess.shape.*;
> import com.bbn.openmap.dataAccess.shape.input.*;
> import com.bbn.openmap.dataAccess.shape.output.*;
>
> public class Modify {
>
> File dbf;
> File shp;
> File shx;
>
> EsriGraphicList egl;
> EsriPlugIn epi;
>
> DbfTableModel dtm;
>
> public Modify () {
>
> // reading ...
> String path = "./hungary";
>
> dbf = new File(path + ".dbf");
> shp = new File(path + ".shp");
> shx = new File(path + ".shx");
>
> epi = new EsriPlugIn("Mo.", dbf.toURL(), shp.toURL(), shx.toURL());
>
> egl = epi.getEsriGraphicList();
> dtm = epi.getModel();
>
> ///////
> // what to do here ?
> ///////
>
> // writing ...
> String opath = "./modified";
>
> ShpOutputStream pos = new ShpOutputStream(new
> FileOutputStream(opath + ".shp"));
> ShxOutputStream xos = new ShxOutputStream(new
> FileOutputStream(opath + ".shx"));
> DbfOutputStream dos = new DbfOutputStream(new
> FileOutputStream(opath + ".dbf"));
>
> int[][] indexData = pos.writeGeometry(egl);
> xos.writeIndex(indexData, egl.getType(), egl.getExtents());
> dos.writeModel(epi.getModel());
> }
>
> public static void main (String args[]) {
> Modify m = new Modify();
> }
> }
>
> -----
>
> Thanks,
> Sass Bálint
> --
> [To unsubscribe to this list send an email to "majdart@bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]
>
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:38 EDT