01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.catalog.ui.export;
16:
17: import org.geotools.feature.FeatureCollection;
18: import org.geotools.feature.FeatureType;
19: import org.geotools.feature.GeometryAttributeType;
20: import org.opengis.referencing.operation.MathTransform;
21:
22: import com.vividsolutions.jts.geom.Geometry;
23: import com.vividsolutions.jts.geom.GeometryFactory;
24: import com.vividsolutions.jts.geom.LineString;
25:
26: /**
27: * Takes a FeatureCollection with features with MultiPointand Point and converts them all to
28: * MultiPoint and returns the features.
29: *
30: * @author Jesse
31: * @since 1.1.0
32: */
33: class ToMultiLineFeatureCollection extends
34: AbstractGeometryTransformingFeatureCollection {
35:
36: public ToMultiLineFeatureCollection(FeatureCollection source,
37: FeatureType schema,
38: GeometryAttributeType typeToUseAsGeometry,
39: MathTransform mt, CountDownProgressMonitor monitor) {
40: super (source, schema, typeToUseAsGeometry, mt, monitor);
41: }
42:
43: @Override
44: protected Geometry toCollection(Geometry geometry) {
45: if (geometry instanceof LineString) {
46: LineString line = (LineString) geometry;
47: GeometryFactory factory = line.getFactory();
48: return factory
49: .createMultiLineString(new LineString[] { line });
50: }
51: return geometry;
52: }
53:
54: }
|