Perforce JViews TGO Sample: Network Component - Geographic Information
Description
This sample demonstrates how to implement load-on-demand of Perforce JViews TGO objects based on data stored in a database server that supports load-on-demand, such as Oracle Spatial.
How to Use the Sample
The default interactor is the pan interactor, which allows you to move the content of the view. The JViews TGO objects are added to the map after the 3rd zoom-in is performed from the startup perspective. The added JViews TGO objects will start receiving alarm notifications in real time. The alarms are generated by a simulator which acts as the back-end application. It sends alarm updates in XML format to the JTGO data source. The ability to zoom-in and zoom-out is controlled. This is done to:
For the precise contraints see network.css
Installation Requirements
You need the Perforce JViews Maps Data DVD. This DVD contains the map data used by this sample (located in the DVD_DRIVE:\Shape
directory).
You can run this sample either off the DVD, or move the data to an Oracle Spatial server and then use the data as stored on the server. In the latter case, you need Oracle Enterprise version 8.1.7 or higher and a JDBC
driver that can be used to connect to the database. In which case you will have to:
- Change the gis.Main's
useOracle
flag totrue
. - Change the database URL connection parameters defined in gis.Main to reflect the settings on your database server.
- Set the environment variable
ORACLE_HOME
so that it holds the location where the OracleJDBC
driver is provided. Seesample.xml
for more details on how this environment variable is used. - If the map data is already stored in the database, you can simply run the sample. Otherwise, you will need to first store the map data in the database by using the provided script
storeData.bat/sh
.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
network-gis.jar
,
that allows you to execute the sample with a double click from a
file browser. Note that if you are using Internet Explorer, you can
open the installation directory
and execute the JAR file from the browser. This
technique may not work in other Web browsers.
Alternatively, you
can run the sample application from the command line.
First check that the Ant utility is properly configured. If not, see the
instructions on how to configure Ant for Perforce JViews.
Then, go to the installation directory
of the sample and type:
ant run
Topics Covered
- Load-on-demand of JTGO objects
- Layer visibility depending on zoom
Detailed Description
Perforce JViews Maps provides three features for loading background maps on demand:
- Tiling, that is, loading precisely those objects that are needed to paint the current visible area
- Connection to common data formats (ShapeFile, ...) and data servers (Oracle) that support load-on-demand
- Rendering of the loaded objects as Perforce JViews graphic objects
IlvFeatureRenderer
that creates JTGO objects instead of Perforce JViews objects.
A JTGO network component is used. It contains an IlvGrapher
into which background and city layers are inserted. The background layers are ordinary Perforce JViews Maps tiled layers. The city layers consist of a tiled layer that will never actually contain any IlvGraphic
object; its sole purpose is to trigger the loading of JTGO objects. This is done by plugging a special IlvFeatureRenderer
that creates an IlpObject
instead of an IlvGraphic
for each point contained in the map file/database.
IlpObject
is added to the data source, and the simulator is requested to send future alarm updates of the new object to the data source.
Performance Issues
The loading of a tile of JTGO objects (city layer) -- triggered by zooming or panning -- is currently slow and blocks the application until it is finished. We are working on multithreaded loading of tiles, that would allow the application to react to user's input while the tile loading is still in progress.The class NetworkTileLoader
is used to delay computation of automatic layout until the loading of a tile is complete.
Known Bug
When you select an area using the mouse-dragging gesture of the select interactor, sometimes only half of the objects inside the depicted rectangle get selected. Sometimes some objects outside this rectangle get selected as well.Notes
The server that stores the spatial data might not be a common one, which would mean writing the connection to that server from scratch. In this particular case, only the first of the three Perforce JViews Maps features (mentioned in the Introduction above) would be interesting for reuse, and therefore it would be simpler to implement a custom IlvTileLoader
instead of a custom IlvFeatureRenderer
. (In the Perforce JViews Maps architecture, the tile loader fetches the map data from the file or server, and uses the feature renderer to create graphic objects. This could be done in one step here.)
When using the sample in oracle mode, there can be a delay when displaying the background and cities while the information is retrived from the database. The view gets automatically refreshed once all the information is available to the client. The actual delay depends on the network latency involved.
Installation Directory
The Network Component - Geographic Information sample is installed here.
Classes Involved
-
ilog.tgo.IltSystem
The class that initializes a JViews TGO application.
-
ilog.tgo.datasource.IltDefaultDataSource
The default datasource implementation.
-
ilog.cpl.IlpNetwork
The network component.
-
ilog.tgo.graphic.IltLayerPolicy
The poligy to manage layers in a network component.
-
ilog.cpl.network.IlpGeographicPosition
The geographic position of an object.
-
ilog.cpl.network.IlpGeographicPositionConverter
The converter between geographic position and view coordinates.
-
ilog.views.maps.IlvFeatureRenderer
The renderer from map features to graphic objects.
-
ilog.views.IlvLayerVisibilityFilter
The layer visibility filter.
-
ilog.views.tiling.IlvTiledLayer
The manager layer to load large sets of data.
Source Files
-
gis.Main
The entry point of the sample.
-
gis.BackgroundLayers
The base class to handle background layers.
-
gis.BackgroundLayersFromFile
The support to load background layers from a file.
-
gis.BackgroundLayersFromOracle
The support to load background layers from an Oracle Spatial Database.
-
gis.CitiesLayers
The manager of the layers displaying the cities.
-
gis.CitiesLayersFromFile
The support to load cities layers from a file.
-
gis.CitiesLayersFromOracle
The support to load cities layers from an Oracle Spatial Database.
-
gis.NetworkTileLoader
The class that optimizes the loading of map tiles in a network component.
-
gis.InteractorWithPan
The interactor that combines an arbitrary JViews view interactor with a pan interactor.
-
gis.SelectWithPanAction
The action that sets a selection interactor with additional pan interactor on the view.
-
gis.SelectWithPanButton
The button that sets a selection interactor with additional pan interactor on the view.
-
gis.DebuggingFeatureRenderer
The maps feature renderer that prints a trace for objects it creates.