twaver.gis.utils
Class GisToolkits

java.lang.Object
  extended bytwaver.gis.utils.GisToolkits

public class GisToolkits
extends java.lang.Object

A collection of utility methods for TWaverGIS.


Constructor Summary
GisToolkits()
           
 
Method Summary
static void addOnReadyListener(OnReadyListener listener)
           
static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map, double longitude, double latitude)
          Converts geographical coordinate to screen coordinate
static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map, twaver.GeoCoordinate co)
          Converts geographical coordinate to screen coordinate
static twaver.GeoCoordinate convertScreenToLatLong(GeographyMap map, double screenX, double screenY)
          Converts screen coordinate to geographical coordinate
static twaver.GeoCoordinate convertScreenToLatLong(GeographyMap map, java.awt.geom.Point2D screenPoint)
          Converts screen coordinate to geographical coordinate
static GeographyMap createDefaultMap()
          Creates a GeographyMap object which displays the map as tiles.
static GeographyFeature createFeture(java.util.List shape, java.lang.String type, java.lang.String[] attributeNames, java.lang.Object[] values)
           
static int getAppropriateZoomLevel(GridBbox bbox, GeographyMap map)
          Gets appropriate zoom level by referring to the specified geographical area.
static double getDegree(double[] degreeDescription)
           
static double getDistance(double fromLongitude, double fromLatitude, double toLongitude, double toLatitude)
           
static java.util.List getFeaturePoints(GeographyMap map, java.util.List list, boolean toScreenPoint, boolean optimize)
           
static java.lang.String getFormatNumber(double value, int decimal)
           
static java.awt.Shape getGeographyFeatureShape(GeographyMap map, GeographyFeature feature)
          Gets the shape of a GeographyFeature.
static twaver.GeoCoordinate getGeoPointFromPixelXY(double pixelx, double pixely, int zoomLevel, int projectionType)
           
static twaver.GeoCoordinate getGeoPointFromScreenPoint(double x, double y, twaver.GeoCoordinate mapCenter, int viewWidth, int viewHeight, int zoomLevel, int projectionType)
          Converts screen point to geographic coordinate according to the specified projection.
static java.awt.Image getImage(java.lang.String path)
          Gets an Image object according to the specified file path.
static javax.swing.ImageIcon getImageIcon(java.lang.String path)
           
static java.awt.geom.Point2D getPixelXY(twaver.GeoCoordinate geoPoint, int zoomLevel, int projectionType)
           
static java.awt.Color getRandomColor()
          Gets a random color.
static java.util.List getRegionPath(GeographyMap map, twaver.ShapeNode region, boolean optimize)
           
static java.awt.geom.Point2D getScreenLocation(twaver.Element element, GeographyMap map)
          Gets the screen location of the an Element object.
static java.awt.geom.Point2D getScreenPointFromGeoPoint(twaver.GeoCoordinate geoPoint, twaver.GeoCoordinate mapCenter, int viewWidth, int viewHeight, int zoomLevel, int projectionType)
          Converts geographical point to screen point according to the specified projection.
static java.lang.String getServerByExecutorType(int executorType)
           
static java.awt.Container getTopContainer(javax.swing.JComponent component)
           
static java.awt.geom.Rectangle2D getVisibleElementsBounds(twaver.network.TNetwork network, GeographyMap map)
          Gets the geographical bounds of all visible elements of the network.
static java.lang.String getWFSCapabilities(int executorType, java.lang.String WFSURL)
          Gets the contents of WFS capabilities.
static java.util.List getWFSLayers(int executorType, java.lang.String WFSURL)
          Gets the layers information of WFS capabilities contents.
static java.util.List getWMSCapabilities(int executorType, java.lang.String WMSURL)
          Gets the WMS capabilities contents.
static void goBack(twaver.network.TNetwork network, GeographyMap map)
          Redo last zoom out or in operation.
static void locateElement(twaver.Element element, GeographyMap map)
          Locates the element on the screen according to the element's geographical coordinate and the map instance.
static void setGeographicalCoordinate(GeographyMap map, twaver.Element element)
          Sets the value of the element's TWaverGisConst.GEOCOORDINATE client property.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GisToolkits

public GisToolkits()
Method Detail

addOnReadyListener

public static void addOnReadyListener(OnReadyListener listener)

convertLatLongToScreen

public static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map,
                                                           double longitude,
                                                           double latitude)
Converts geographical coordinate to screen coordinate

Parameters:
map - the referential map object
longitude - the longitude of the specified geographical point
latitude - the latitude of the specified geographical point
Returns:
the corresponding point on the screen of the specified geographical point

convertLatLongToScreen

public static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map,
                                                           twaver.GeoCoordinate co)
Converts geographical coordinate to screen coordinate

Parameters:
map - the referential map object
co - the geographical point's coordinate
Returns:
the corresponding point on the screen of the specified geographical point

convertScreenToLatLong

public static twaver.GeoCoordinate convertScreenToLatLong(GeographyMap map,
                                                          double screenX,
                                                          double screenY)
Converts screen coordinate to geographical coordinate

Parameters:
map - the map instance according which to convert the coordinates.
screenX - the x value of the specified screen coordinate
screenY - the y value of the specified screen coordinate
Returns:
the corresponding geographical coordinate

convertScreenToLatLong

public static twaver.GeoCoordinate convertScreenToLatLong(GeographyMap map,
                                                          java.awt.geom.Point2D screenPoint)
Converts screen coordinate to geographical coordinate

Parameters:
map - the map instance according which to convert the coordinates
screenPoint - the location of the point on the screen.
Returns:
the corresponding geographical coordinate

createDefaultMap

public static GeographyMap createDefaultMap()
Creates a GeographyMap object which displays the map as tiles.

Returns:
a GeographyMap object supporting tiles map.

createFeture

public static GeographyFeature createFeture(java.util.List shape,
                                            java.lang.String type,
                                            java.lang.String[] attributeNames,
                                            java.lang.Object[] values)

getAppropriateZoomLevel

public static int getAppropriateZoomLevel(GridBbox bbox,
                                          GeographyMap map)
Gets appropriate zoom level by referring to the specified geographical area.

Parameters:
bbox - the specified geographical area.
map - relative GeographyMap object
Returns:
the appropriate zoom level

getDegree

public static double getDegree(double[] degreeDescription)

getDistance

public static double getDistance(double fromLongitude,
                                 double fromLatitude,
                                 double toLongitude,
                                 double toLatitude)

getFeaturePoints

public static java.util.List getFeaturePoints(GeographyMap map,
                                              java.util.List list,
                                              boolean toScreenPoint,
                                              boolean optimize)

getFormatNumber

public static java.lang.String getFormatNumber(double value,
                                               int decimal)

getGeographyFeatureShape

public static java.awt.Shape getGeographyFeatureShape(GeographyMap map,
                                                      GeographyFeature feature)
Gets the shape of a GeographyFeature. TWaverGIS can create GeographyFeature objects though WFS. Every feature contains geometric attribute which describe the track of a geographical feature. But the track is described by latitude and longitude coordinate. This method can return the shape of the track and the shape is described by x/y coordinate.

Parameters:
map - the referential map object.
feature - the source GeographyFeature object.
Returns:
the relative shape.

getGeoPointFromPixelXY

public static twaver.GeoCoordinate getGeoPointFromPixelXY(double pixelx,
                                                          double pixely,
                                                          int zoomLevel,
                                                          int projectionType)

getGeoPointFromScreenPoint

public static twaver.GeoCoordinate getGeoPointFromScreenPoint(double x,
                                                              double y,
                                                              twaver.GeoCoordinate mapCenter,
                                                              int viewWidth,
                                                              int viewHeight,
                                                              int zoomLevel,
                                                              int projectionType)
Converts screen point to geographic coordinate according to the specified projection.

Parameters:
x - x value of the screen point
y - y value of the screen point
mapCenter - the center geographical point of the map
viewWidth - the width of view port
viewHeight - the height of view port
zoomLevel - the specified zoom
projectionType - the specified projection type
Returns:
the result geographic coordinate
See Also:
TWaverGisConst.PROJECTIONTYPE_4326, TWaverGisConst.PROJECTIONTYPE_MERCATOR

getImage

public static final java.awt.Image getImage(java.lang.String path)
Gets an Image object according to the specified file path.

Parameters:
path - the specified file path. Like 'file:/e:/test/a.png' or 'http://www.sss.com/a.png' or '/project/resources/c.png'
Returns:
an Image object relative to the file path.

getImageIcon

public static final javax.swing.ImageIcon getImageIcon(java.lang.String path)

getPixelXY

public static java.awt.geom.Point2D getPixelXY(twaver.GeoCoordinate geoPoint,
                                               int zoomLevel,
                                               int projectionType)

getRandomColor

public static java.awt.Color getRandomColor()
Gets a random color.

Returns:
a random color

getRegionPath

public static java.util.List getRegionPath(GeographyMap map,
                                           twaver.ShapeNode region,
                                           boolean optimize)

getScreenLocation

public static java.awt.geom.Point2D getScreenLocation(twaver.Element element,
                                                      GeographyMap map)
Gets the screen location of the an Element object. In TWaver GIS, GeoCoordinate object is used to describe the element's latitude and longitude, and the coordinate object should be stored as a client property named TWaverGisConst.GEOCOORDINATE.

Parameters:
element - the target element
map - the relative map object
Returns:
if the element contains the valid latitude and longitude information return the element's location described by x and y coordinate; otherwise, return null.

getScreenPointFromGeoPoint

public static java.awt.geom.Point2D getScreenPointFromGeoPoint(twaver.GeoCoordinate geoPoint,
                                                               twaver.GeoCoordinate mapCenter,
                                                               int viewWidth,
                                                               int viewHeight,
                                                               int zoomLevel,
                                                               int projectionType)
Converts geographical point to screen point according to the specified projection.

Parameters:
geoPoint - the specified geographical point
mapCenter - the center geographical point of the map
viewWidth - the width of view port
viewHeight - the height of view port
zoomLevel - the specified zoom
projectionType - the specified projection type
Returns:
the result screen point
See Also:
TWaverGisConst.PROJECTIONTYPE_4326, TWaverGisConst.PROJECTIONTYPE_MERCATOR

getServerByExecutorType

public static java.lang.String getServerByExecutorType(int executorType)

getTopContainer

public static java.awt.Container getTopContainer(javax.swing.JComponent component)

getVisibleElementsBounds

public static java.awt.geom.Rectangle2D getVisibleElementsBounds(twaver.network.TNetwork network,
                                                                 GeographyMap map)
Gets the geographical bounds of all visible elements of the network.

Parameters:
network - the network object contains the whole topological datas
map - the reference map
Returns:
the bounds of all the visible topological elements.

getWFSCapabilities

public static java.lang.String getWFSCapabilities(int executorType,
                                                  java.lang.String WFSURL)
Gets the contents of WFS capabilities.

Parameters:
executorType - the specified executor type. TWaverGIS implements the getCapabilities interface of the WFS provided by GeoServer.
WFSURL - the specified server's URL.
Returns:
the contents of WFS's capabilities

getWFSLayers

public static java.util.List getWFSLayers(int executorType,
                                          java.lang.String WFSURL)
Gets the layers information of WFS capabilities contents.

Parameters:
executorType - the specified executor type. TWaverGIS implements the getCapabilities interface of the WFS provided by GeoServer.
WFSURL - the specified server's URL.
Returns:
the layers' information of the result of the getCapabilities interface.

getWMSCapabilities

public static java.util.List getWMSCapabilities(int executorType,
                                                java.lang.String WMSURL)
Gets the WMS capabilities contents.

Parameters:
executorType - the specified executor type. TWaverGIS implements the getCapabilities interface of the WMS provided by GeoServer, ArcGIS and MapXtream.
WMSURL - the specified server's URL.
Returns:
the layers' information of the result of the getCapabilities interface.

goBack

public static void goBack(twaver.network.TNetwork network,
                          GeographyMap map)
Redo last zoom out or in operation.

Parameters:
network - the specified TNetwork object.
map - the relative map object.

locateElement

public static void locateElement(twaver.Element element,
                                 GeographyMap map)
Locates the element on the screen according to the element's geographical coordinate and the map instance.

Parameters:
element - an Element object with the client property TWaverGisConst.GEOCOORDINATE.
map - the specified map instance.

setGeographicalCoordinate

public static void setGeographicalCoordinate(GeographyMap map,
                                             twaver.Element element)
Sets the value of the element's TWaverGisConst.GEOCOORDINATE client property.

Parameters:
map - the referential map object
element - the target which should be located on the correct position of the screen.