|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.dataAccess.shape.EsriShapeExport
public class EsriShapeExport
Provides methods for saving OMGraphicLists as ShapeFiles. This code was originally submitted by Karl Stuempfle of OptiMetrics, and I modified it a little to add a user interface to modify the DBF files if the user wants to.
Since Shape files can only hold one type of graphic, this class will create one to three different lists as needed, for points, lines and polygons.
If the OMGraphicList's AppObject holds a DbfTableModel, it will be used for the shape file database file.
Nested Class Summary | |
---|---|
class |
EsriShapeExport.ESEInterface
A helper class to manage a specific instance of a EsriGraphicList, it's data model, etc. |
Field Summary | |
---|---|
protected boolean |
dbfHasRenderingInfo
Flad to note whether, if a DbfTableModel is set, to add the rendering information (DrawingAttributes contents) about the OMGraphics to the contents of the DbfTableModel. |
protected boolean |
DEBUG
Gets set automatically if Logger.isLoggable(Level.INFO); |
protected java.util.ArrayList<EsriShapeExport.ESEInterface> |
eseInterfaces
A list of ESEInterface classes, holding information for different type ESRIGraphicLists created from the OMGraphicList. |
protected java.lang.String |
filePath
The path where the shape files should be written. |
protected javax.swing.JFrame |
frame
|
protected OMGraphicList |
graphicList
The source graphics to write to a shape file. |
protected EsriPolylineList |
lineList
|
static java.lang.String |
LineSuffix
|
static java.util.logging.Logger |
logger
|
protected DbfTableModel |
masterDBF
The optional DbfTableModel that describes properties for the OMGraphics. |
protected EsriPointList |
pointList
|
static java.lang.String |
PointSuffix
|
protected EsriPolygonList |
polyList
|
protected Projection |
projection
The projection needed to convert other OMGraphicTypes to polygons. |
protected GeoCoordTransformation |
transform
A GeoCoordTransform to use to convert Lat/Lon values in EsriGraphics to projected coordinates. |
protected boolean |
writeDBF
Flag for whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file. |
Constructor Summary | |
---|---|
EsriShapeExport(EsriGraphicList list,
DbfTableModel dbf,
java.lang.String pathToFile)
Create an EsriShapeExport object. |
|
EsriShapeExport(OMGraphicList list,
Projection proj,
java.lang.String pathToFile)
Create an EsriShapeExport object. |
Method Summary | |
---|---|
protected void |
addAreaList(OMAreaList omal,
java.util.List<java.lang.Object> record)
Scoping method to call addGraphic with contents of OMAreaList. |
protected void |
addGraphic(EsriGraphicList egl,
OMGraphic graphic,
java.util.List<java.lang.Object> record)
Add a graphic to the list, and add the record to the list's DbfTableModel if both exist. |
protected void |
addLine(OMGraphic graphic,
java.util.List<java.lang.Object> record)
Scoping method to call addGraphic with the right list. |
protected void |
addPoint(OMGraphic graphic,
java.util.List<java.lang.Object> record)
Scoping method to call addGraphic with the right list. |
protected void |
addPolygon(OMGraphic graphic,
java.util.List<java.lang.Object> record)
Scoping method to call addGraphic with the right list. |
protected double[] |
combineCoords(double[] orig,
double[] addCoords)
Utility method to concatenate coordinate arrays. |
static DbfTableModel |
createDefaultModel(EsriGraphicList list)
Prepares and returns a 7 column DbfTableModel to accept input for columns of TYPE_CHARACTER. |
void |
export()
Separates the graphics from the OMGraphicList into Polygon, Polyline and Point lists, then passes the desired shape lists to their respective export functions to be added to an EsriLayer of the same type and prepared for export. |
protected void |
export(EsriGraphicList egList)
Writes out EsriGraphicLists as shape files, assumes that the DbfTableModel representing the attribute data for the list objects is stored as an attribute in the EsriGraphicList under the DBF_ATTRIBUTE key. |
protected void |
export(OMGraphicList list,
java.util.List<java.lang.Object> record)
Deprecated. use export(OMGraphicList, ArrayList, boolean) instead. |
protected void |
export(OMGraphicList list,
java.util.List<java.lang.Object> masterRecord,
boolean writeFiles)
This method is intended to allow embedded OMGraphicLists to be handled. |
protected double[] |
gatherCoords(OMGeometry omg,
double[] current)
Walk through OMGeometry, that may be a OMList of Geometries (OMAreaList) and concatentate the coordinates to make one big poly. |
boolean |
getDBFHasRenderingInfo()
Get whether the DBF file should have the DrawingAttributes information added to the DbfTableModel if it isn't already there. |
java.lang.String |
getFilePath()
|
java.lang.String |
getFilePathFromUser()
Fetches a file path from the user, via a JFileChooser. |
OMGraphicList |
getGraphicList()
|
java.awt.Component |
getGUI()
Create the GUI for managing the different ESEIterators. |
protected java.util.Iterator<EsriShapeExport.ESEInterface> |
getInterfaces()
The the Iterator of ESEIterators. |
protected EsriPolylineList |
getLineList()
Return the line list, create it if needed. |
DbfTableModel |
getMasterDBF()
Get the DbfTableModel representing the dbf file for the main OMGraphicList. |
protected DbfTableModel |
getMasterDBFHeaderClone()
If the OMGraphicList has a DbfTableModel in its AppObject slot, a new DbfTableModel is created that has the same structure. |
protected java.util.List<java.lang.Object> |
getMasterDBFRecord(int index)
Gets the DbfTableModel record at the index. |
protected EsriPointList |
getPointList()
Return the point list, create it if needed. |
protected EsriPolygonList |
getPolyList()
Return the polygon list, create it if needed. |
Projection |
getProjection()
|
GeoCoordTransformation |
getTransform()
|
boolean |
getWriteDBF()
Get whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file. |
protected void |
handleException(java.lang.Exception e)
Generic error handling, puts up an error window. |
void |
hideGUI()
Hide the Frame holding the GUI. |
static boolean |
isPolygon(OMPoly omPoly)
Takes an OMPoly as the parameter and checks whether or not it is a polygon or polyline. |
static void |
main(java.lang.String[] argv)
The main function is a test, reads in a Shape file (with the .shx and .dbf files) and writes them back out. |
static OMGraphicList |
read(java.net.URL shpFileURL,
DrawingAttributes drawingAttributes,
GeoCoordTransformation coordTransform)
|
void |
setDBFHasRenderingInfo(boolean value)
Get whether the DBF file should have the DrawingAttributes information added to the DbfTableModel if it isn't already there. |
void |
setFilePath(java.lang.String pathToFile)
|
void |
setGraphicList(OMGraphicList list)
Set the OMGraphicList to use for export. |
void |
setMasterDBF(DbfTableModel dbf)
Set the DbfTableModel representing the dbf file for the main OMGraphicList. |
void |
setProjection(Projection proj)
|
void |
setTransform(GeoCoordTransformation transform)
|
void |
setWriteDBF(boolean value)
Set whether the DBF file should be written when the OMGraphicList is exported to a .shp/.shx file. |
void |
showGUI()
Show the GUI for saving the Shape files. |
static void |
syncDrawingAttributesToTableModel(DbfTableModel model,
OMGraphicList list,
boolean clearUpdatedStatus)
|
protected void |
writeFiles()
Just write the files from the ESEInterfaces. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
protected OMGraphicList graphicList
protected DbfTableModel masterDBF
protected Projection projection
protected java.lang.String filePath
protected boolean DEBUG
protected java.util.ArrayList<EsriShapeExport.ESEInterface> eseInterfaces
protected boolean writeDBF
protected boolean dbfHasRenderingInfo
protected GeoCoordTransformation transform
protected EsriPolygonList polyList
protected EsriPolylineList lineList
protected EsriPointList pointList
public static final java.lang.String LineSuffix
public static final java.lang.String PointSuffix
protected javax.swing.JFrame frame
Constructor Detail |
---|
public EsriShapeExport(OMGraphicList list, Projection proj, java.lang.String pathToFile)
list
- the OMGraphicList to export.proj
- the Projection of the map, needed to convert some OMGraphic
types to OMPolys.pathToFile
- the file path of the shape file to save to. If null,
the user will be queried. If not null, the files will be saved
without any GUI confirmation.public EsriShapeExport(EsriGraphicList list, DbfTableModel dbf, java.lang.String pathToFile)
list
- the EsriGraphicList to export.dbf
- the DbfTableModel holding the attributes for the list objects.pathToFile
- the file path of the shape file to save to. If null,
the user will be queried. If not null, the files will be saved
without any GUI confirmation.Method Detail |
---|
public void setGraphicList(OMGraphicList list)
public OMGraphicList getGraphicList()
public void setProjection(Projection proj)
public Projection getProjection()
public void setFilePath(java.lang.String pathToFile)
public java.lang.String getFilePath()
public GeoCoordTransformation getTransform()
public void setTransform(GeoCoordTransformation transform)
protected EsriPolygonList getPolyList()
protected EsriPolylineList getLineList()
protected EsriPointList getPointList()
protected void addGraphic(EsriGraphicList egl, OMGraphic graphic, java.util.List<java.lang.Object> record)
protected void addPolygon(OMGraphic graphic, java.util.List<java.lang.Object> record)
protected void addLine(OMGraphic graphic, java.util.List<java.lang.Object> record)
protected void addPoint(OMGraphic graphic, java.util.List<java.lang.Object> record)
protected void addAreaList(OMAreaList omal, java.util.List<java.lang.Object> record)
protected double[] gatherCoords(OMGeometry omg, double[] current)
omg
- current OMGeometrycurrent
- the current coord list.
protected double[] combineCoords(double[] orig, double[] addCoords)
orig
- addCoords
-
public void setMasterDBF(DbfTableModel dbf)
public DbfTableModel getMasterDBF()
public void setWriteDBF(boolean value)
public boolean getWriteDBF()
public void setDBFHasRenderingInfo(boolean value)
public boolean getDBFHasRenderingInfo()
protected DbfTableModel getMasterDBFHeaderClone()
protected java.util.List<java.lang.Object> getMasterDBFRecord(int index)
public void export()
Separating the graphics into the three types is necessary due to shape file specification limitations which will only allow shape files to be of one type.
For OMGraphicLists that are actually EsriGraphicLists, this export method will be redirected to a different method that will handle sub-OMGraphicLists as multi-part geometries.
If you want to write out multi-part geometries and have a regular OMGraphicList, you have to convert them to EsriGraphicLists first (and OMGraphics to EsriGraphics), which forces you to group shapes into like types (points, polylines and polygons).
protected void export(OMGraphicList list, java.util.List<java.lang.Object> record)
list
- the OMGraphicList to writerecord
- the record for the current list, used if the list is
actually a multipart geometry for the overall list. May be null
anyway, though.export(OMGraphicList list, List masterRecord, boolean writeFiles)
protected void export(OMGraphicList list, java.util.List<java.lang.Object> masterRecord, boolean writeFiles)
list
- the OMGraphicList to write.masterRecord
- the record for the current list, used if the list is
actually a multipart geometry for the overall list. May be null
anyway, though.writeFiles
- Flag to note when this method is being called
iteratively, which is when record is not null. If it is iterative,
then the writing of the files should not be performed on this
round of the method call.protected void export(EsriGraphicList egList)
protected java.util.Iterator<EsriShapeExport.ESEInterface> getInterfaces()
protected void writeFiles()
public void showGUI()
public void hideGUI()
public java.awt.Component getGUI()
public static DbfTableModel createDefaultModel(EsriGraphicList list)
list
- the EsriGraphicList to create a DbfTableModel from.
public static void syncDrawingAttributesToTableModel(DbfTableModel model, OMGraphicList list, boolean clearUpdatedStatus)
public static boolean isPolygon(OMPoly omPoly)
omPoly
- the OMPoly object to be verified
protected void handleException(java.lang.Exception e)
public java.lang.String getFilePathFromUser()
FileUtils.getFilePathToSaveFromUser(String)
public static void main(java.lang.String[] argv)
public static OMGraphicList read(java.net.URL shpFileURL, DrawingAttributes drawingAttributes, GeoCoordTransformation coordTransform)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |