shapefile header fields, File Length

View: New views
14 Messages — Rating Filter:   Alert me  

shapefile header fields, File Length

by Reese, Nathan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

shapefile header fields, File Length

I am having problems opening shapefiles generated with OpenMap using various GIS applications (although the shapefile can be opened in GE and with ArcGIS).  The shapefiles can only be opened by all GIS applications by first opening and resaving the file with ArcGIS.

I have compared the orginal .shp file with the ArcGIS updated .shp and have found that the only difference is in the File Length field in the main file header (byte 27).  I have tried using the ShapeFile class to display the shapefile header information, but that utility always returns a value of 100 for the File Length.  Has any one experienced these types of problems.  Does ShpOutputStream properly set the File Length field in the main file header?

Thanks,

Nathan 


Re: shapefile header fields, File Length

by Don Dietrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Nathan,

The file length is calculated for the shapes being placed in the  
file.  What kind of shape type are you creating a file for, and what  
classes are you using to do it?

- Don

On Oct 19, 2009, at 1:41 PM, Reese, Nathan wrote:

> I am having problems opening shapefiles generated with OpenMap using  
> various GIS applications (although the shapefile can be opened in GE  
> and with ArcGIS).  The shapefiles can only be opened by all GIS  
> applications by first opening and resaving the file with ArcGIS.
>
> I have compared the orginal .shp file with the ArcGIS updated .shp  
> and have found that the only difference is in the File Length field  
> in the main file header (byte 27).  I have tried using the ShapeFile  
> class to display the shapefile header information, but that utility  
> always returns a value of 100 for the File Length.  Has any one  
> experienced these types of problems.  Does ShpOutputStream properly  
> set the File Length field in the main file header?
>
> Thanks,
>
> Nathan
>



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, openmap@...
BBN Technologies, Cambridge MA, USA
http://openmap.bbn.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]

How can I keep OpenMap updated in real time according to the CSV file updates?

by Moe Zakeri :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
shapefile header fields, File Length

I am trying to keep OpenMap updated in real time according to the CSV file updates/changes that I need to make. For example, if I add a new city, or change its location in the CSV file it won’t be displayed on the map while I have the OpenMap running. Currently I can see the updates/changes on the map by reloading the properties file. Is there any other way to set this to auto reload for example in every 5 seconds?

 

Thanks,

 

Moe

 


Parent Message unknown RE: How do I set OpenMap to be zoomed at a location from CSV file or anywhere else in the settings?

by Moe Zakeri :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
shapefile header fields, File Length

Is there any way to zoom at a city/location based on the settings, so when I run the OpenMap it is zoomed to that location like a GPS?

 

Thanks,

Moe

 


Re: How do I set OpenMap to be zoomed at a location from CSV file or anywhere else in the settings?

by Paweł Skarżyński :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Moe,

The starting projection is in the openmap properties file:
# MAP STARTUP PROJECTION PARAMETERS
# Latitude and longitude in decimal degrees
openmap.Latitude=20f
openmap.Longitude=-20f

Paul S.


2009/10/19 Moe Zakeri <mzakeri@...>

Is there any way to zoom at a city/location based on the settings, so when I run the OpenMap it is zoomed to that location like a GPS?

 

Thanks,

Moe

 



RE: shapefile header fields, File Length

by Reese, Nathan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RE: [OpenMap Users] shapefile header fields, File Length

I am creating a shapefile with polygons.  Below is the code fragment that I am using to generate a shapefile, I have omitted dbf and shx code for simplicity.  Let me know if you need any additional information.

EsriLayer polygonLayer = new EsriLayer("testShapefile", ShapeConstants.SHAPE_TYPE_POLYGON, 7);

//Build dbf table
...

//Build layer
while (ellipses to add to layer) {
  OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis, minorAxis, Length.NM, Math.toRadians(azimuth-90));
  float[] ellipsePoints = ellipse.createLatLonPoints();
  EsriPolygon poly = new EsriPolygon(ellipsePoints, 1, 0);
  ArrayList<String> attributes = new ArrayList<String>();
  ...
  polygonLayer.addRecord(poly, attributes);
}

//Write file
FileOutputStream shpFileStream = new FileOutputStream("testShapefile.shp");
ShpOutputStream shpStream = new ShpOutputStream(shpFileStream);
EsriGraphicList list = polygonLayer.getEsriGraphicList();
int[][] imageData = shpStream.writeGeometry(list);

//write dbf and shx files
...

shpFileStream.close();


Thanks,

Nathan

-----Original Message-----
From: Don Dietrick [dietrick@...]
Sent: Mon 10/19/2009 2:37 PM
To: Reese, Nathan
Cc: openmap-users@...
Subject: Re: [OpenMap Users] shapefile header fields, File Length

Hi Nathan,

The file length is calculated for the shapes being placed in the 
file.  What kind of shape type are you creating a file for, and what 
classes are you using to do it?

- Don

On Oct 19, 2009, at 1:41 PM, Reese, Nathan wrote:

> I am having problems opening shapefiles generated with OpenMap using 
> various GIS applications (although the shapefile can be opened in GE 
> and with ArcGIS).  The shapefiles can only be opened by all GIS 
> applications by first opening and resaving the file with ArcGIS.
>
> I have compared the orginal .shp file with the ArcGIS updated .shp 
> and have found that the only difference is in the File Length field 
> in the main file header (byte 27).  I have tried using the ShapeFile 
> class to display the shapefile header information, but that utility 
> always returns a value of 100 for the File Length.  Has any one 
> experienced these types of problems.  Does ShpOutputStream properly 
> set the File Length field in the main file header?
>
> Thanks,
>
> Nathan
>



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, openmap@...
BBN Technologies, Cambridge MA, USA
http://openmap.bbn.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




Re: How do I set OpenMap to be zoomed at a location from CSV file or anywhere else in the settings?

by Don Dietrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Moe,

Paul suggestion is the correct one for adjusting the starting  
location. You can also set the openmap.Scale and openmap.Projection  
values to adjust the other projection parameters.

If you are using the GoToMenu in the properties file, you can set pre-
defined areas.  An example:

gotoMenu.class=com.bbn.openmap.gui.GoToMenu
gotoMenu.addDefaults=true
goto.views=Argentina India Massachusetts United_States Caspian_Sea  
Russia
Russia.latitude=40.20
Russia.longitude=46.500
Russia.name=Russia
Russia.projection=Mercator
Russia.scale=5.0E7
Argentina.latitude=-39.760445
Argentina.longitude=-65.92294
Argentina.name=Argentina
Argentina.projection=Mercator
Argentina.scale=5.0E7
...

Also, if your Layer/object implements the DataBoundsProvider  
interface, The GoToMenu will ask it for a DataBounds to use to add to  
its menu for predefined view based on a dataset.

Hope this helps,

Don


On Oct 20, 2009, at 1:29 AM, Paweł Skarżyński wrote:

> Hi Moe,
>
> The starting projection is in the openmap properties file:
> # MAP STARTUP PROJECTION PARAMETERS
> # Latitude and longitude in decimal degrees
> openmap.Latitude=20f
> openmap.Longitude=-20f
>
> Paul S.
>
>
> 2009/10/19 Moe Zakeri <mzakeri@...>
> Is there any way to zoom at a city/location based on the settings,  
> so when I run the OpenMap it is zoomed to that location like a GPS?
>
>
> Thanks,
>
> Moe
>
>
>

--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]

Re: shapefile header fields, File Length

by Don Dietrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Nathan,

I admit I haven't tested this method of doing this, but your code  
looks like it should work. I'll give it a shot later.

  If I were going to create a shape file, I'd do something like this;

OMGraphicList omgl = new OMGraphicList();

... add OMGraphics to omgl

DbfTableModel dbf = new DbfTableModel(..);

... add entries appropriate for OMGraphics

EsriShapeExport ese = EsriShapeExport(omgl, dbf, my_file_path);
ese.export();

- Don

On Oct 20, 2009, at 10:44 AM, Reese, Nathan wrote:

> I am creating a shapefile with polygons.  Below is the code fragment  
> that I am using to generate a shapefile, I have omitted dbf and shx  
> code for simplicity.  Let me know if you need any additional  
> information.
>
> EsriLayer polygonLayer = new EsriLayer("testShapefile",  
> ShapeConstants.SHAPE_TYPE_POLYGON, 7);
>
> //Build dbf table
> ...
>
> //Build layer
> while (ellipses to add to layer) {
>   OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis,  
> minorAxis, Length.NM, Math.toRadians(azimuth-90));
>   float[] ellipsePoints = ellipse.createLatLonPoints();
>   EsriPolygon poly = new EsriPolygon(ellipsePoints, 1, 0);
>   ArrayList<String> attributes = new ArrayList<String>();
>   ...
>   polygonLayer.addRecord(poly, attributes);
> }
>
> //Write file
> FileOutputStream shpFileStream = new FileOutputStream
> ("testShapefile.shp");
> ShpOutputStream shpStream = new ShpOutputStream(shpFileStream);
> EsriGraphicList list = polygonLayer.getEsriGraphicList();
> int[][] imageData = shpStream.writeGeometry(list);
>
> //write dbf and shx files
> ...
>
> shpFileStream.close();
>
>
> Thanks,
>
> Nathan
>
> -----Original Message-----
> From: Don Dietrick [mailto:dietrick@...]
> Sent: Mon 10/19/2009 2:37 PM
> To: Reese, Nathan
> Cc: openmap-users@...
> Subject: Re: [OpenMap Users] shapefile header fields, File Length
>
> Hi Nathan,
>
> The file length is calculated for the shapes being placed in the
> file.  What kind of shape type are you creating a file for, and what
> classes are you using to do it?
>
> - Don
>
> On Oct 19, 2009, at 1:41 PM, Reese, Nathan wrote:
>
> > I am having problems opening shapefiles generated with OpenMap using
> > various GIS applications (although the shapefile can be opened in GE
> > and with ArcGIS).  The shapefiles can only be opened by all GIS
> > applications by first opening and resaving the file with ArcGIS.
> >
> > I have compared the orginal .shp file with the ArcGIS updated .shp
> > and have found that the only difference is in the File Length field
> > in the main file header (byte 27).  I have tried using the ShapeFile
> > class to display the shapefile header information, but that utility
> > always returns a value of 100 for the File Length.  Has any one
> > experienced these types of problems.  Does ShpOutputStream properly
> > set the File Length field in the main file header?
> >
> > Thanks,
> >
> > Nathan
> >
>
>
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Don Dietrick, openmap@...
> BBN Technologies, Cambridge MA, USA
> http://openmap.bbn.com
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
>
>

--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]

RE: How to make the map updated with new positions?

by Moe Zakeri :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
shapefile header fields, File Length

We need to put updated positions plus an image for each position on the OpenMap based on latitude and longitude. How this could be done in either properties or the anywhere in OpenMap API?

Already I have created a CSV file based on cities.csv and called it positions.csv, then I have set it up in the properties file. But this shows static positions and no images for the positions.

 

Thank you,

Moe

 


Re: How to make the map updated with new positions?

by Paweł Skarżyński :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Moe,
If you decide to put your locations in CSV file you should read documentation for classes:
1. com.bbn.openmap.layer.location.LocationLayer
2. com.bbn.openmap.layer.location.csv.CSVLocationHandler

For displaying images you need to add a property for CSVLocationHandler (in properties file), for example:
csvcities.defaultIconURL = data/city.png
I assume that you sucessfully display your locations as red rectangles.

Sorry for my English
Paul S.



2009/10/21 Moe Zakeri <mzakeri@...>

We need to put updated positions plus an image for each position on the OpenMap based on latitude and longitude. How this could be done in either properties or the anywhere in OpenMap API?

Already I have created a CSV file based on cities.csv and called it positions.csv, then I have set it up in the properties file. But this shows static positions and no images for the positions.

 

Thank you,

Moe

 



RE: shapefile header fields, File Length

by Reese, Nathan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RE: [OpenMap Users] shapefile header fields, File Length

Don,

I have reworked my shapefile generation code to use the classes suggested.  See the code fragment below.

EsriGraphicList polygonList = new EsriPolygonList();
DbfTableModel polygonModel = new DbfTableModel(7);

//Build graphics
while (ellipses to add) {
   OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis, 
 minorAxis, Length.NM, Math.toRadians(azimuth-90));
   float[] ellipsePoints = ellipse.createLatLonPoints();
   OMPoly polyGraphic = new OMPoly(ellipsePoints, OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_GREATCIRCLE);
   polygonList.add(polyGraphic);

   ArrayList<String> attributes = new ArrayList<String>();
   ...
   polygonModel.addRecord(attributes);
}

//Write files
EsriShapeExport ese = new EsriShapeExport(polygonList, polygonModel, "testShapefile");
ese.export();


The shapefile generated with the reworked method is identical to the shapefile generated with the original method, including the file length header field.  Have you had a chance to dig into the length generation code and see if anything is amiss?

Thanks,

Nathan


-----Original Message-----
From: Don Dietrick [dietrick@...]
Sent: Tue 10/20/2009 11:33 AM
To: Reese, Nathan
Cc: openmap-users@...
Subject: Re: [OpenMap Users] shapefile header fields, File Length

Hi Nathan,

I admit I haven't tested this method of doing this, but your code 
looks like it should work. I'll give it a shot later.

  If I were going to create a shape file, I'd do something like this;

OMGraphicList omgl = new OMGraphicList();

... add OMGraphics to omgl

DbfTableModel dbf = new DbfTableModel(..);

... add entries appropriate for OMGraphics

EsriShapeExport ese = EsriShapeExport(omgl, dbf, my_file_path);
ese.export();

- Don

On Oct 20, 2009, at 10:44 AM, Reese, Nathan wrote:

> I am creating a shapefile with polygons.  Below is the code fragment 
> that I am using to generate a shapefile, I have omitted dbf and shx 
> code for simplicity.  Let me know if you need any additional 
> information.
>
> EsriLayer polygonLayer = new EsriLayer("testShapefile", 
> ShapeConstants.SHAPE_TYPE_POLYGON, 7);
>
> //Build dbf table
> ...
>
> //Build layer
> while (ellipses to add to layer) {
>   OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis, 
> minorAxis, Length.NM, Math.toRadians(azimuth-90));
>   float[] ellipsePoints = ellipse.createLatLonPoints();
>   EsriPolygon poly = new EsriPolygon(ellipsePoints, 1, 0);
>   ArrayList<String> attributes = new ArrayList<String>();
>   ...
>   polygonLayer.addRecord(poly, attributes);
> }
>
> //Write file
> FileOutputStream shpFileStream = new FileOutputStream
> ("testShapefile.shp");
> ShpOutputStream shpStream = new ShpOutputStream(shpFileStream);
> EsriGraphicList list = polygonLayer.getEsriGraphicList();
> int[][] imageData = shpStream.writeGeometry(list);
>
> //write dbf and shx files
> ...
>
> shpFileStream.close();
>
>
> Thanks,
>
> Nathan
>
> -----Original Message-----
> From: Don Dietrick [dietrick@...]
> Sent: Mon 10/19/2009 2:37 PM
> To: Reese, Nathan
> Cc: openmap-users@...
> Subject: Re: [OpenMap Users] shapefile header fields, File Length
>
> Hi Nathan,
>
> The file length is calculated for the shapes being placed in the
> file.  What kind of shape type are you creating a file for, and what
> classes are you using to do it?
>
> - Don
>
> On Oct 19, 2009, at 1:41 PM, Reese, Nathan wrote:
>
> > I am having problems opening shapefiles generated with OpenMap using
> > various GIS applications (although the shapefile can be opened in GE
> > and with ArcGIS).  The shapefiles can only be opened by all GIS
> > applications by first opening and resaving the file with ArcGIS.
> >
> > I have compared the orginal .shp file with the ArcGIS updated .shp
> > and have found that the only difference is in the File Length field
> > in the main file header (byte 27).  I have tried using the ShapeFile
> > class to display the shapefile header information, but that utility
> > always returns a value of 100 for the File Length.  Has any one
> > experienced these types of problems.  Does ShpOutputStream properly
> > set the File Length field in the main file header?
> >
> > Thanks,
> >
> > Nathan
> >
>
>
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Don Dietrick, openmap@...
> BBN Technologies, Cambridge MA, USA
> http://openmap.bbn.com
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
>
>



Re: shapefile header fields, File Length

by Don Dietrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Nathan,

I've just checked a couple of shape files that I've recently created via
the method outlined below and the header information seems reasonable,
and the reading code isn't complaining about file length mismatches.

- Don

Reese, Nathan wrote:

>
> Don,
>
> I have reworked my shapefile generation code to use the classes
> suggested.  See the code fragment below.
>
> EsriGraphicList polygonList = new EsriPolygonList();
> DbfTableModel polygonModel = new DbfTableModel(7);
>
> //Build graphics
> while (ellipses to add) {
>    OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis,
>  minorAxis, Length.NM, Math.toRadians(azimuth-90));
>    float[] ellipsePoints = ellipse.createLatLonPoints();
>    OMPoly polyGraphic = new OMPoly(ellipsePoints,
> OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_GREATCIRCLE);
>    polygonList.add(polyGraphic);
>
>    ArrayList<String> attributes = new ArrayList<String>();
>    ...
>    polygonModel.addRecord(attributes);
> }
>
> //Write files
> EsriShapeExport ese = new EsriShapeExport(polygonList, polygonModel,
> "testShapefile");
> ese.export();
>
>
> The shapefile generated with the reworked method is identical to the
> shapefile generated with the original method, including the file
> length header field.  Have you had a chance to dig into the length
> generation code and see if anything is amiss?
>
> Thanks,
>
> Nathan
>
>
> -----Original Message-----
> From: Don Dietrick [mailto:dietrick@...]
> Sent: Tue 10/20/2009 11:33 AM
> To: Reese, Nathan
> Cc: openmap-users@...
> Subject: Re: [OpenMap Users] shapefile header fields, File Length
>
> Hi Nathan,
>
> I admit I haven't tested this method of doing this, but your code
> looks like it should work. I'll give it a shot later.
>
>   If I were going to create a shape file, I'd do something like this;
>
> OMGraphicList omgl = new OMGraphicList();
>
> ... add OMGraphics to omgl
>
> DbfTableModel dbf = new DbfTableModel(..);
>
> ... add entries appropriate for OMGraphics
>
> EsriShapeExport ese = EsriShapeExport(omgl, dbf, my_file_path);
> ese.export();
>
> - Don
>
> On Oct 20, 2009, at 10:44 AM, Reese, Nathan wrote:
>
> > I am creating a shapefile with polygons.  Below is the code fragment
> > that I am using to generate a shapefile, I have omitted dbf and shx
> > code for simplicity.  Let me know if you need any additional
> > information.
> >
> > EsriLayer polygonLayer = new EsriLayer("testShapefile",
> > ShapeConstants.SHAPE_TYPE_POLYGON, 7);
> >
> > //Build dbf table
> > ...
> >
> > //Build layer
> > while (ellipses to add to layer) {
> >   OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis,
> > minorAxis, Length.NM, Math.toRadians(azimuth-90));
> >   float[] ellipsePoints = ellipse.createLatLonPoints();
> >   EsriPolygon poly = new EsriPolygon(ellipsePoints, 1, 0);
> >   ArrayList<String> attributes = new ArrayList<String>();
> >   ...
> >   polygonLayer.addRecord(poly, attributes);
> > }
> >
> > //Write file
> > FileOutputStream shpFileStream = new FileOutputStream
> > ("testShapefile.shp");
> > ShpOutputStream shpStream = new ShpOutputStream(shpFileStream);
> > EsriGraphicList list = polygonLayer.getEsriGraphicList();
> > int[][] imageData = shpStream.writeGeometry(list);
> >
> > //write dbf and shx files
> > ...
> >
> > shpFileStream.close();
> >
> >
> > Thanks,
> >
> > Nathan
> >
> > -----Original Message-----
> > From: Don Dietrick [mailto:dietrick@...]
> > Sent: Mon 10/19/2009 2:37 PM
> > To: Reese, Nathan
> > Cc: openmap-users@...
> > Subject: Re: [OpenMap Users] shapefile header fields, File Length
> >
> > Hi Nathan,
> >
> > The file length is calculated for the shapes being placed in the
> > file.  What kind of shape type are you creating a file for, and what
> > classes are you using to do it?
> >
> > - Don
> >
> > On Oct 19, 2009, at 1:41 PM, Reese, Nathan wrote:
> >
> > > I am having problems opening shapefiles generated with OpenMap using
> > > various GIS applications (although the shapefile can be opened in GE
> > > and with ArcGIS).  The shapefiles can only be opened by all GIS
> > > applications by first opening and resaving the file with ArcGIS.
> > >
> > > I have compared the orginal .shp file with the ArcGIS updated .shp
> > > and have found that the only difference is in the File Length field
> > > in the main file header (byte 27).  I have tried using the ShapeFile
> > > class to display the shapefile header information, but that utility
> > > always returns a value of 100 for the File Length.  Has any one
> > > experienced these types of problems.  Does ShpOutputStream properly
> > > set the File Length field in the main file header?
> > >
> > > Thanks,
> > >
> > > Nathan
> > >
> >
> >
> >
> > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > Don Dietrick, openmap@...
> > BBN Technologies, Cambridge MA, USA
> > http://openmap.bbn.com
> > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> >
> >
> >
> >
>
>

--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]

RE: shapefile header fields, File Length

by Reese, Nathan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RE: [OpenMap Users] shapefile header fields, File Length

Hi Don,

I have found the problem!  The class ShpOutputStream.java calculates file content length by adding the position of the last record and the last record's content length.  However, a record's content length does not include the record header.  As a result, the file content length is always off by 4.  After correcting the problem, ArgGIS had no problems ingesting the shapefile generated with OpenMap.

Attached is an updated version of ShpOutputStream.java containing the fixes (I only fixed the problem for shapefiles containing polygons).  This is the first time I have ever found and fixed a bug in an OpenSource project.  How do I submit my changes to the project?

Nathan

-----Original Message-----
From: Don Dietrick [dietrick@...]
Sent: Mon 10/26/2009 4:44 PM
To: Reese, Nathan
Cc: openmap-users@...
Subject: Re: [OpenMap Users] shapefile header fields, File Length

Hi Nathan,

I've just checked a couple of shape files that I've recently created via
the method outlined below and the header information seems reasonable,
and the reading code isn't complaining about file length mismatches.

- Don

Reese, Nathan wrote:
>
> Don,
>
> I have reworked my shapefile generation code to use the classes
> suggested.  See the code fragment below.
>
> EsriGraphicList polygonList = new EsriPolygonList();
> DbfTableModel polygonModel = new DbfTableModel(7);
>
> //Build graphics
> while (ellipses to add) {
>    OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis,
>  minorAxis, Length.NM, Math.toRadians(azimuth-90));
>    float[] ellipsePoints = ellipse.createLatLonPoints();
>    OMPoly polyGraphic = new OMPoly(ellipsePoints,
> OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_GREATCIRCLE);
>    polygonList.add(polyGraphic);
>
>    ArrayList<String> attributes = new ArrayList<String>();
>    ...
>    polygonModel.addRecord(attributes);
> }
>
> //Write files
> EsriShapeExport ese = new EsriShapeExport(polygonList, polygonModel,
> "testShapefile");
> ese.export();
>
>
> The shapefile generated with the reworked method is identical to the
> shapefile generated with the original method, including the file
> length header field.  Have you had a chance to dig into the length
> generation code and see if anything is amiss?
>
> Thanks,
>
> Nathan
>
>
> -----Original Message-----
> From: Don Dietrick [dietrick@...]
> Sent: Tue 10/20/2009 11:33 AM
> To: Reese, Nathan
> Cc: openmap-users@...
> Subject: Re: [OpenMap Users] shapefile header fields, File Length
>
> Hi Nathan,
>
> I admit I haven't tested this method of doing this, but your code
> looks like it should work. I'll give it a shot later.
>
>   If I were going to create a shape file, I'd do something like this;
>
> OMGraphicList omgl = new OMGraphicList();
>
> ... add OMGraphics to omgl
>
> DbfTableModel dbf = new DbfTableModel(..);
>
> ... add entries appropriate for OMGraphics
>
> EsriShapeExport ese = EsriShapeExport(omgl, dbf, my_file_path);
> ese.export();
>
> - Don
>
> On Oct 20, 2009, at 10:44 AM, Reese, Nathan wrote:
>
> > I am creating a shapefile with polygons.  Below is the code fragment
> > that I am using to generate a shapefile, I have omitted dbf and shx
> > code for simplicity.  Let me know if you need any additional
> > information.
> >
> > EsriLayer polygonLayer = new EsriLayer("testShapefile",
> > ShapeConstants.SHAPE_TYPE_POLYGON, 7);
> >
> > //Build dbf table
> > ...
> >
> > //Build layer
> > while (ellipses to add to layer) {
> >   OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis,
> > minorAxis, Length.NM, Math.toRadians(azimuth-90));
> >   float[] ellipsePoints = ellipse.createLatLonPoints();
> >   EsriPolygon poly = new EsriPolygon(ellipsePoints, 1, 0);
> >   ArrayList<String> attributes = new ArrayList<String>();
> >   ...
> >   polygonLayer.addRecord(poly, attributes);
> > }
> >
> > //Write file
> > FileOutputStream shpFileStream = new FileOutputStream
> > ("testShapefile.shp");
> > ShpOutputStream shpStream = new ShpOutputStream(shpFileStream);
> > EsriGraphicList list = polygonLayer.getEsriGraphicList();
> > int[][] imageData = shpStream.writeGeometry(list);
> >
> > //write dbf and shx files
> > ...
> >
> > shpFileStream.close();
> >
> >
> > Thanks,
> >
> > Nathan
> >
> > -----Original Message-----
> > From: Don Dietrick [dietrick@...]
> > Sent: Mon 10/19/2009 2:37 PM
> > To: Reese, Nathan
> > Cc: openmap-users@...
> > Subject: Re: [OpenMap Users] shapefile header fields, File Length
> >
> > Hi Nathan,
> >
> > The file length is calculated for the shapes being placed in the
> > file.  What kind of shape type are you creating a file for, and what
> > classes are you using to do it?
> >
> > - Don
> >
> > On Oct 19, 2009, at 1:41 PM, Reese, Nathan wrote:
> >
> > > I am having problems opening shapefiles generated with OpenMap using
> > > various GIS applications (although the shapefile can be opened in GE
> > > and with ArcGIS).  The shapefiles can only be opened by all GIS
> > > applications by first opening and resaving the file with ArcGIS.
> > >
> > > I have compared the orginal .shp file with the ArcGIS updated .shp
> > > and have found that the only difference is in the File Length field
> > > in the main file header (byte 27).  I have tried using the ShapeFile
> > > class to display the shapefile header information, but that utility
> > > always returns a value of 100 for the File Length.  Has any one
> > > experienced these types of problems.  Does ShpOutputStream properly
> > > set the File Length field in the main file header?
> > >
> > > Thanks,
> > >
> > > Nathan
> > >
> >
> >
> >
> > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > Don Dietrick, openmap@...
> > BBN Technologies, Cambridge MA, USA
> > http://openmap.bbn.com
> > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> >
> >
> >
> >
>
>





ShpOutputStream.java (19K) Download Attachment

Re: shapefile header fields, File Length

by Don Dietrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Nathan,

Thanks for sending in the fix, I'll incorporate your change into the
code base. and I'll make sure the other data types are covered, too.

Thanks again,

Don

Reese, Nathan wrote:

>
> Hi Don,
>
> I have found the problem!  The class ShpOutputStream.java calculates
> file content length by adding the position of the last record and the
> last record's content length.  However, a record's content length does
> not include the record header.  As a result, the file content length
> is always off by 4.  After correcting the problem, ArgGIS had no
> problems ingesting the shapefile generated with OpenMap.
>
> Attached is an updated version of ShpOutputStream.java containing the
> fixes (I only fixed the problem for shapefiles containing polygons).  
> This is the first time I have ever found and fixed a bug in an
> OpenSource project.  How do I submit my changes to the project?
>
> Nathan
>
> -----Original Message-----
> From: Don Dietrick [mailto:dietrick@...]
> Sent: Mon 10/26/2009 4:44 PM
> To: Reese, Nathan
> Cc: openmap-users@...
> Subject: Re: [OpenMap Users] shapefile header fields, File Length
>
> Hi Nathan,
>
> I've just checked a couple of shape files that I've recently created via
> the method outlined below and the header information seems reasonable,
> and the reading code isn't complaining about file length mismatches.
>
> - Don
>
> Reese, Nathan wrote:
> >
> > Don,
> >
> > I have reworked my shapefile generation code to use the classes
> > suggested.  See the code fragment below.
> >
> > EsriGraphicList polygonList = new EsriPolygonList();
> > DbfTableModel polygonModel = new DbfTableModel(7);
> >
> > //Build graphics
> > while (ellipses to add) {
> >    OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis,
> >  minorAxis, Length.NM, Math.toRadians(azimuth-90));
> >    float[] ellipsePoints = ellipse.createLatLonPoints();
> >    OMPoly polyGraphic = new OMPoly(ellipsePoints,
> > OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_GREATCIRCLE);
> >    polygonList.add(polyGraphic);
> >
> >    ArrayList<String> attributes = new ArrayList<String>();
> >    ...
> >    polygonModel.addRecord(attributes);
> > }
> >
> > //Write files
> > EsriShapeExport ese = new EsriShapeExport(polygonList, polygonModel,
> > "testShapefile");
> > ese.export();
> >
> >
> > The shapefile generated with the reworked method is identical to the
> > shapefile generated with the original method, including the file
> > length header field.  Have you had a chance to dig into the length
> > generation code and see if anything is amiss?
> >
> > Thanks,
> >
> > Nathan
> >
> >
> > -----Original Message-----
> > From: Don Dietrick [mailto:dietrick@...]
> > Sent: Tue 10/20/2009 11:33 AM
> > To: Reese, Nathan
> > Cc: openmap-users@...
> > Subject: Re: [OpenMap Users] shapefile header fields, File Length
> >
> > Hi Nathan,
> >
> > I admit I haven't tested this method of doing this, but your code
> > looks like it should work. I'll give it a shot later.
> >
> >   If I were going to create a shape file, I'd do something like this;
> >
> > OMGraphicList omgl = new OMGraphicList();
> >
> > ... add OMGraphics to omgl
> >
> > DbfTableModel dbf = new DbfTableModel(..);
> >
> > ... add entries appropriate for OMGraphics
> >
> > EsriShapeExport ese = EsriShapeExport(omgl, dbf, my_file_path);
> > ese.export();
> >
> > - Don
> >
> > On Oct 20, 2009, at 10:44 AM, Reese, Nathan wrote:
> >
> > > I am creating a shapefile with polygons.  Below is the code fragment
> > > that I am using to generate a shapefile, I have omitted dbf and shx
> > > code for simplicity.  Let me know if you need any additional
> > > information.
> > >
> > > EsriLayer polygonLayer = new EsriLayer("testShapefile",
> > > ShapeConstants.SHAPE_TYPE_POLYGON, 7);
> > >
> > > //Build dbf table
> > > ...
> > >
> > > //Build layer
> > > while (ellipses to add to layer) {
> > >   OMEllipse ellipse = new OMEllipse(centerPoint, majorAxis,
> > > minorAxis, Length.NM, Math.toRadians(azimuth-90));
> > >   float[] ellipsePoints = ellipse.createLatLonPoints();
> > >   EsriPolygon poly = new EsriPolygon(ellipsePoints, 1, 0);
> > >   ArrayList<String> attributes = new ArrayList<String>();
> > >   ...
> > >   polygonLayer.addRecord(poly, attributes);
> > > }
> > >
> > > //Write file
> > > FileOutputStream shpFileStream = new FileOutputStream
> > > ("testShapefile.shp");
> > > ShpOutputStream shpStream = new ShpOutputStream(shpFileStream);
> > > EsriGraphicList list = polygonLayer.getEsriGraphicList();
> > > int[][] imageData = shpStream.writeGeometry(list);
> > >
> > > //write dbf and shx files
> > > ...
> > >
> > > shpFileStream.close();
> > >
> > >
> > > Thanks,
> > >
> > > Nathan
> > >
> > > -----Original Message-----
> > > From: Don Dietrick [mailto:dietrick@...]
> > > Sent: Mon 10/19/2009 2:37 PM
> > > To: Reese, Nathan
> > > Cc: openmap-users@...
> > > Subject: Re: [OpenMap Users] shapefile header fields, File Length
> > >
> > > Hi Nathan,
> > >
> > > The file length is calculated for the shapes being placed in the
> > > file.  What kind of shape type are you creating a file for, and what
> > > classes are you using to do it?
> > >
> > > - Don
> > >
> > > On Oct 19, 2009, at 1:41 PM, Reese, Nathan wrote:
> > >
> > > > I am having problems opening shapefiles generated with OpenMap using
> > > > various GIS applications (although the shapefile can be opened in GE
> > > > and with ArcGIS).  The shapefiles can only be opened by all GIS
> > > > applications by first opening and resaving the file with ArcGIS.
> > > >
> > > > I have compared the orginal .shp file with the ArcGIS updated .shp
> > > > and have found that the only difference is in the File Length field
> > > > in the main file header (byte 27).  I have tried using the ShapeFile
> > > > class to display the shapefile header information, but that utility
> > > > always returns a value of 100 for the File Length.  Has any one
> > > > experienced these types of problems.  Does ShpOutputStream properly
> > > > set the File Length field in the main file header?
> > > >
> > > > Thanks,
> > > >
> > > > Nathan
> > > >
> > >
> > >
> > >
> > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > > Don Dietrick, openmap@...
> > > BBN Technologies, Cambridge MA, USA
> > > http://openmap.bbn.com
> > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > >
> > >
> > >
> > >
> >
> >
>
>
>

--
[To unsubscribe to this list send an email to "majdart@..."
with the following text in the BODY of the message "unsubscribe openmap-users"]