This plug-in is used to perform a line merge on similar features.
The Need
We typically use state Department of Transportation (DOT) GIS data to display roadway networks. We load the data into a PostGIS table and use GeoServer's WMS to generate the map. One pr the problems we have with typical DOT data is that a single roadway is not represented by a single GIS feature but rather by a number of independent features, many of these features spanning less than a mile of roadway. The problem arises when we try to label the roadway via WMS. What happens is that each feature is labeled when what we want is one label for a roadway, regardless of how many individual features are used to constitute that roadway.
The Solution
What we have written is a plug-in that intercepts the query of features from a PostGIS database and aggregates multiple features for a single roadway into one feature that is then returned to the WMS for rendering. To identify which features belong to a single roadway, an attribute is specified when the Data Store is created that holds the roadway names. All features with the same value for this attribute are merged together into a single feature. The result is that, at any given zoom level, only one feature is returned for a single roiadwat and only one label is drawn.
Installing the Plug-in
To install the plug-in, copy the plug-in JAR (LineMergerPostgisPlugin-1.0.jar) to GeoServer's WEB-INF/lib directory. Upon startup, GeoServerwill automatically detect the plug-in and add the new Data Store to GeoServer.
Plug-in Details
The following source files make up the plug-in.
| Classes |
Description |
|---|---|
| LineMergerFeatureReader | This class reads the data from the PostGIS database and performs the line merger. |
| LineMergerPostgisDataStore | This class is the Data Store. |
| LineMergerPostgisDataStoreFactory | This class creates the Data Store. |
Along with these classes, there is one configuration file.
| Configuration file |
Description |
|---|---|
| org.geotools.data.DataStoreFactorySpi | This file registers the data store plugin. This file is saved in the META-INF/services directory of the JAR. |
Building the Plug-in
This plug-in is built with ant and ivy.