Class GeoRelationalStore

All Implemented Interfaces:
PopupActivationListener, SpatialStore, Serializable, Comparable, EventListener, ListSelectionListener, TableModelListener, TableModel
Direct Known Subclasses:
NetworkTable, RouteTable

public class GeoRelationalStore extends RelationalStore implements SpatialStore
See Also:
Serialized Form
  • Constructor Details

  • Method Details

    • openOrReuseGeo

      public static AttributeStore openOrReuseGeo(String spec) throws Exception
      Open a GeoRelationalStore data set. If the data set is already open and exists in the cache, then return the cached version. Otherwise open a new copy and add it to the cache.
      Parameters:
      spec - A string that specifies the data set to open (either a filename or tablespec string).
      Returns:
      Returns the handle to the data set.
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • open

      public static GeoRelationalStore open(String spec) throws Exception
      Open up a store by name. THe cache is not checked.
      Parameters:
      spec - A string that specifies the data set to open (either a filename or tablespec string).
      Returns:
      Returns the handle to the data set.
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • open

      public static GeoRelationalStore open(String spec, String encoding) throws Exception
      Open up a store by name. THe cache is not checked.
      Parameters:
      spec - A string that specifies the data set to open (either a filename or tablespec string).
      Returns:
      Returns the handle to the data set.
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • openShapeFile

      public static GeoRelationalStore openShapeFile(String origFilename) throws Exception
      Deprecated.
      Use the open(String) method instead
      Open up a shapefile and it's related DBF file
      Parameters:
      origFilename - The name of the file to open
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • openShapeFile

      public static GeoRelationalStore openShapeFile(String origFilename, String encoding) throws Exception
      Deprecated.
      Use the open(String,String) method instead
      Open up a shapefile and it's related DBF file
      Parameters:
      origFilename - The name of the file to open
      encoding - The character set encoding to use for this data set.
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • openCoverage

      public static GeoRelationalStore openCoverage(String workspace, String coverage, int type, boolean cache) throws Exception
      Open up a coverage and it's related INFO file using an explicit feature type.
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • openCoverage

      public static GeoRelationalStore openCoverage(String workspace, String coverage, boolean cache) throws Exception
      Open up a coverage and it's related INFO file by guessing the feature type.
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • openRamShapeFile

      public static GeoRelationalStore openRamShapeFile(String filename) throws Exception
      Open up a shapefile and it's related DBF file
      Throws:
      Exception - An exception if the file cannot be opened or is not a GeoRelational data set.
    • maybePopup

      public void maybePopup(MouseEvent e, double x, double y, double fuzz, int period)
    • addMenuItems

      public void addMenuItems(JPopupMenu jpm, AttributeStore l, int row, int period)
      Description copied from class: AttributeStore
      Add menu items to be displayed when a popup menu is activated on this table. This method when a popup mouse click happens on a map layer, just before the popup menu appears. Each layer is given an opportunity to add menu items into the popup that are specific to the functionality that the layer provides. The menu items that are added must contain the functionality to perform the requested action.
      Specified by:
      addMenuItems in interface PopupActivationListener
      Overrides:
      addMenuItems in class AttributeStore
      Parameters:
      jpm - The menu that the items should be added into
      l - The main AttributeStore that initiated this request. This may be different than the current AttributeStore if the main table is a RelationalStore composed of a number of parts.
      row - The row in the table that this event applies to
      period - The period that the request applies to.
    • getThemeList

      public ArrayList<ThemeDescriptor> getThemeList()
    • addTheme

      public void addTheme(Theme theme)
    • addTheme

      public void addTheme(Theme theme, String description)
    • addRelate

      public GeoRelationalStore addRelate(AttributeStore join, String column1, String column2) throws Exception
      Join a table to the current table, creating a new table having columns from both. The method returns a reference to the new table. You must use the table provided in the reference to see the join. The old table will not have changed at all.

      When you are finished using the new table then simply drop the reference to it, and it will be garbage collected.

      Overrides:
      addRelate in class AttributeStore
      Parameters:
      join - The table that should be joined to this table
      column1 - The foreign key in the original table
      column2 - The primary key in the table to be joined
      Returns:
      The joined RelationalStore
      Throws:
      Exception - if errors occur while setting up the relate
    • addRelate

      public GeoRelationalStore addRelate(AttributeStore join, String column1, String column2, int rowDelta) throws Exception
      Description copied from class: AttributeStore
      Join a table to the current table, creating a new table having columns from both. The method returns a reference to the new table. You must use the table provided in the reference to see the join. The old table will not have changed at all.

      When you are finished using the new table then simply drop the reference to it, and it will be garbage collected.

      Overrides:
      addRelate in class AttributeStore
      Parameters:
      join - The table that should be joined to this table
      column1 - The foreign key in the original table
      column2 - The primary key in the table to be joined
      rowDelta - A row offset between the two tables that is used when the tables are joined by row number.
      Returns:
      The joined RelationalStore
      Throws:
      Exception - if errors occur while setting up the relate
    • getSnapshot

      public AttributeStore getSnapshot(boolean useSelected, Observer progress)
      Description copied from class: AttributeStore
      Return a snapshot of the dataset at a given moment. The general behaviour of this method is to simply return the same datastore. Some specialized datastores (such as CrosstabStore), will compute an instance that can be used and then disposed.

      The default behaviour simply returns 'this'.

      Overrides:
      getSnapshot in class RelationalStore
      Parameters:
      useSelected - If true then only use the currently selected records in computing the snapshot.
      progress - An optional progress bar. This parameter may be null.
      Returns:
      An AttributeStore representing a materialization of the store.
    • getProjectionInfo

      public String getProjectionInfo()
      Description copied from interface: SpatialStore
      Obtain projection information.
      Specified by:
      getProjectionInfo in interface SpatialStore
    • records

      public Iterator<Integer> records()
      Description copied from interface: SpatialStore
      Return an Iterator for all the records in the table
      Specified by:
      records in interface SpatialStore
    • records

      public Iterator<Integer> records(Extent2D extent)
      Description copied from interface: SpatialStore
      Return an Iterator for the records that fall within the selection rectangle
      Specified by:
      records in interface SpatialStore
    • records

      public Iterator<Integer> records(double x, double y, double width, double height)
      Description copied from interface: SpatialStore
      Return an Iterator for the records that fall within the selection rectangle
      Specified by:
      records in interface SpatialStore
    • getType

      public int getType()
      Description copied from interface: SpatialStore
      Specified by:
      getType in interface SpatialStore
    • getShape

      public GeoShape getShape(int row)
      Description copied from interface: SpatialStore
      Get the shape object for a individual feature
      Specified by:
      getShape in interface SpatialStore
      Parameters:
      row - The record of interest
      Returns:
      A shape object
    • getShape

      public GeoShape getShape(int row, int period)
      Description copied from interface: SpatialStore
      Get the shape object for a individual feature
      Specified by:
      getShape in interface SpatialStore
      Parameters:
      row - The record of interest
      period - The period of interest
      Returns:
      A shape object
    • getCoordinates

      public double[][] getCoordinates(int id)
      Description copied from interface: SpatialStore
      Get a list of raw coordinates for the points in this shape.
      Specified by:
      getCoordinates in interface SpatialStore
      Parameters:
      id - The row of interest
      Returns:
      An array of arrays of coordinate points. Each element in the outer array contains a 'part' of the underlying shape (for example, and island or a multi-part polygon). The inner array index holds the coordinate points of that part.
    • getExtent2D

      public Extent2D getExtent2D(int id)
      Description copied from interface: SpatialStore
      Get the enclosing rectangle of a feature
      Specified by:
      getExtent2D in interface SpatialStore
      Parameters:
      id - The record of interest
      Returns:
      A rectangle
    • getExtent2D

      public Extent2D getExtent2D(int id, int period)
      Description copied from interface: SpatialStore
      Get the enclosing rectangle of a feature
      Specified by:
      getExtent2D in interface SpatialStore
      Parameters:
      id - The record of interest
      period - The period of interest
      Returns:
      A rectangle
    • getExtent2D

      public Extent2D getExtent2D()
      Description copied from interface: SpatialStore
      Get the enclosing rectangle of all features in the table
      Specified by:
      getExtent2D in interface SpatialStore
      Returns:
      A rectangle
    • getSelection

      public BitSet getSelection(Extent2D extent)
      Description copied from interface: SpatialStore
      Get a set of records that fall within the selection rectangle.
      Specified by:
      getSelection in interface SpatialStore
      Parameters:
      extent - The selection rectangle of interest
      Returns:
      A set of selected records
    • hasSpatialIndex

      public boolean hasSpatialIndex()
      Description copied from interface: SpatialStore
      Query if this SpatialStore has a spatial index
      Specified by:
      hasSpatialIndex in interface SpatialStore
    • canBuildSpatialIndex

      public boolean canBuildSpatialIndex()
      Description copied from interface: SpatialStore
      Query if this SpatialStore is capable of building a spatial index
      Specified by:
      canBuildSpatialIndex in interface SpatialStore
    • makeSpatialIndex

      public void makeSpatialIndex() throws Exception
      Description copied from interface: SpatialStore
      Request that this SpatialStore create a spatial index
      Specified by:
      makeSpatialIndex in interface SpatialStore
      Throws:
      Exception
    • reuseOrLoadTopology

      public Topology reuseOrLoadTopology(String filename, double distance, String label)
      Access a previously loaded topology file, or if not already loaded then input a topology dataset for an arbitrary spatial dataset.

      This routine will return a topology dataset. This routine will not change the default block topology. You may call this routine at any time.

      Parameters:
      filename - The file containing the topological relationships.
      distance - A value that is used to filter records from the topology file. Only neighbours that are within the filter distance are loaded from the topology file.
      label - The name of the field in the spatial dataset that uniquely identifies each row.
    • findTopology

      public Topology findTopology(String filename, double distance, String label)
    • findTopology

      public Topology findTopology(double distance)
    • loadTopology

      public Topology loadTopology(String filename, double distance, String label)
      Input a topology dataset for an arbitrary spatial dataset.

      This routine will load a topology dataset. This routine will not change the default block topology. You may call this routine at any time.

      Parameters:
      filename - The file containing the topological relationships.
      distance - A value that is used to filter records from the topology file. Only neighbours that are within the filter distance are loaded from the topology file.
      label - The name of the field in the spatial dataset that uniquely identifies each row.
    • loadTopology

      public Topology loadTopology(String filename, double distance, String label, HashMap sizeLu)
    • getTopologies

      public Set<Topology> getTopologies()
    • copyTopology

      public void copyTopology(GeoRelationalStore other)
    • getAssociatedNetworkTable

      public GeoRelationalStore getAssociatedNetworkTable()
    • setAssociatedNetworkTable

      public void setAssociatedNetworkTable(GeoRelationalStore table)
    • getIntersectedBlocks

      public BitSet getIntersectedBlocks(BitSet in)
    • getRecord

      public GeoShape getRecord(double x, double y, double fuzz)
      Find a record by its x,y location
    • selectRecords

      public void selectRecords(Extent2D box, boolean add)
      Select records that overlap the box.
      Parameters:
      box - The extent to test for overlaps
      add - If true add records to the selection, if false then remove records from the selection.
    • identifyRecords

      public void identifyRecords(Extent2D box)
    • processRecords

      public void processRecords(Extent2D box, RecordHandler handler)
    • getSelectedExtent

      public Extent2D getSelectedExtent()
      Compute the extent of the selected records
    • selectRecords

      public void selectRecords(org.locationtech.jts.geom.Geometry g, boolean add, boolean within)
      Select records that intersect the Geometry.
      Parameters:
      g - the Geometry to test
      add - If true add records to the selection, if false then remove records from the selection.
    • selectRecords

      public BitSet selectRecords(org.locationtech.jts.geom.Geometry poly, String operator)
    • selectRecords

      public BitSet selectRecords(org.locationtech.jts.geom.Geometry poly, SpatialOperator operator)
    • selectByLocation

      public BitSet selectByLocation(String locSourceExpr, GeoRelationalStore locSource, String operator, double distance, int period)
      The method will calculate the selection of records based on a proximity to selected features in a second data source. The selection is returned as a BitSet, with each selected record represented as a selected bit.

      In the following example the operator will first select all features from the point dataset where "Type = 'HQ'" in period 0. These features will be buffered by 1000 units. The resulting polygon(s) will be used to test features from blocks dataset. All blocks features that are within the buffer will be included in the selected set.

       blocks.selectByLocation("Type = 'HQ'", points,
                               "WITHIN", 1000, 0);
       
      Parameters:
      locSourceExpr - an expression that will select the records to buffer from the second data source
      locSource - the second data source
      operator - The selection operator used when comparing features to the buffer (either "INTERSECTS" or "WITHIN")
      distance - the buffering distance to be applied to each feature from the second data source
      period - The planning period to use when applying the selection expression
    • selectByLocation

      public BitSet selectByLocation(String locSourceExpr, GeoRelationalStore locSource, SpatialOperator operator, double distance, int period)
      The method will calculate the selection of records based on a proximity to selected features in a second data source. The selection is returned as a BitSet, with each selected record represented as a selected bit.

      In the following example the operator will first select all features from the point dataset where "Type = 'HQ'" in period 0. These features will be buffered by 1000 units. The resulting polygon(s) will be used to test features from blocks dataset. All blocks features that are within the buffer will be included in the selected set.

       blocks.selectByLocation("Type = 'HQ'", points,
                               SpatialOperator.WITHIN, 1000, 0);
       
      Parameters:
      locSourceExpr - an expression that will select the records to buffer from the second data source
      locSource - the second data source
      operator - The selection operator used when comparing features to the buffer (either INTERSECTS or WITHIN)
      distance - the buffering distance to be applied to each feature from the second data source
      period - The planning period to use when applying the selection expression
    • selectWithinConvexHull

      public void selectWithinConvexHull(String select, int period, boolean add, boolean within)
      Select records that fall within the convex hull of the records specified by the expression.
      Parameters:
      select - An expression that specifies what records to select.
      add - If true add records to the selection, if false then remove records from the selection.
    • selectWithinConvexHull

      public BitSet selectWithinConvexHull(String select, String operator, int period)
      Select records that fall within the convex hull of the records specified by the expression.
      Parameters:
      select - An expression that specifies what records to select.
    • selectWithinConvexHull

      public BitSet selectWithinConvexHull(String select, SpatialOperator operator, int period)
      Select records that fall within the convex hull of the records specified by the expression.
      Parameters:
      select - An expression that specifies what records to select.