If you are implementing any feature data service for your uDig based application, you can improve your data connection speed and display speed quite easily by providing certain query hints. I have implemented this technique in one of my data format( Intergraph MDB).
During connection time uDig tries to calculate the total bound for all GeoResources. Unless you provide better hint to the underline database, it will try to fetch all attributes which are unnecessary. You need only geometry data to calculate the total bound. Following way can help you to implement hints to the underline database -
FeatureSource implementation:
protected FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
String typeName, Query query) throws IOException {
FeatureReader<SimpleFeatureType, SimpleFeature> reader = null;
if (query != null ) {
// use Filter to create optimized FeatureReader
String props[] = query.getPropertyNames();
boolean onlyGeom = false;
if (props != null && props.length == 1
&& "the_geom".equalsIgnoreCase(props[0]))
onlyGeom = true;
if (onlyGeom) {
Map<Object, Object> hint = new HashMap<Object, Object>();
hint.put(MSAccessFeatureReader.GEOM, true);
reader = new MSAccessFeatureReader(this, typeName, hint);
}
}
// default
if (reader == null) {
reader = super.getFeatureReader(typeName, query);
}
return reader;
}
FeatureReader implementation contains the following code:
if (hint != null && hint.containsKey(MSAccessFeatureReader.GEOM)) {
featureBuilder = new SimpleFeatureBuilder(
(SimpleFeatureType) createDefaultGeomType());
this.rsFeature = getFeatureResultSet("Select " + geomFieldName + "," + keyFieldName + " From " + "[" + orgFeatureClassName + "]");
}
By the above implementation definitely your connection speed will improve.
No comments:
Post a Comment