Revision 35725

View differences:

tags/v1_11_0_Build_1306/libraries/libTopology/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry excluding="com/vividsolutions/jcs/|org/geotools/referencefork/metadata/iso/ApplicationSchemaInformationImpl.java|org/geotools/referencefork/metadata/iso/ExtendedElementInformationImpl.java|org/geotools/referencefork/metadata/iso/FeatureCatalogueDescriptionImpl.java|org/geotools/referencefork/metadata/iso/FeatureTypeListImpl.java|org/geotools/referencefork/metadata/iso/IdentifierImpl.java|org/geotools/referencefork/metadata/iso/MetadataExtensionInformationImpl.java|org/geotools/referencefork/metadata/iso/MetaDataImpl.java|org/geotools/referencefork/metadata/iso/package-info.java|org/geotools/referencefork/metadata/iso/PortrayalCatalogueReferenceImpl.java|org/geotools/referencefork/metadata/iso/SpatialAttributeSupplementImpl.java|org/geotools/referencefork/metadata/sql/|org/geotools/referencefork/metadata/iso/constraint/|org/geotools/referencefork/metadata/iso/content/|org/geotools/referencefork/metadata/iso/distribution/|org/geotools/referencefork/metadata/iso/identification/|org/geotools/referencefork/metadata/iso/lineage/|org/geotools/referencefork/metadata/iso/maintenance/|org/geotools/referencefork/metadata/iso/spatial/DimensionImpl.java|org/geotools/referencefork/metadata/iso/spatial/GeometricObjectsImpl.java|org/geotools/referencefork/metadata/iso/spatial/GeorectifiedImpl.java|org/geotools/referencefork/metadata/iso/spatial/GeoreferenceableImpl.java|org/geotools/referencefork/metadata/iso/spatial/GridSpatialRepresentationImpl.java|org/geotools/referencefork/metadata/iso/spatial/package-info.java|org/geotools/referencefork/metadata/iso/spatial/SpatialRepresentationImpl.java|org/geotools/referencefork/metadata/iso/spatial/VectorSpatialRepresentationImpl.java|org/geotools/referencefork/resources/BoundingBoxes.java|org/geotools/referencefork/metadata/iso/citation/AddressImpl.java|org/geotools/referencefork/metadata/iso/citation/CitationDateImpl.java|org/geotools/referencefork/metadata/iso/citation/CitationImpl.java|org/geotools/referencefork/metadata/iso/citation/ContactImpl.java|org/geotools/referencefork/metadata/iso/citation/OnLineResourceImpl.java|org/geotools/referencefork/metadata/iso/citation/package-info.java|org/geotools/referencefork/metadata/iso/citation/ResponsiblePartyImpl.java|org/geotools/referencefork/metadata/iso/citation/SeriesImpl.java|org/geotools/referencefork/metadata/iso/citation/TelephoneImpl.java|org/geotools/referencefork/parameter/ImagingParameterDescriptors.java|org/geotools/referencefork/metadata/iso/citation/Citations.java|org/geotools/referencefork/parameter/ImagingParameters.java|org/geotools/referencefork/nature/|org/geotools/referencefork/resources/jaxb/|org/geotools/referencefork/util/logging/CommonsLogger.java|org/geotools/referencefork/util/logging/CommonsLoggerFactory.java|org/geotools/referencefork/util/logging/Log4JLogger.java|org/geotools/referencefork/util/logging/Log4JLoggerFactory.java|org/geotools/referencefork/util/DateRange.java|org/geotools/referencefork/util/GenericName.java|org/geotools/referencefork/util/LocalName.java|org/geotools/referencefork/util/MeasurementRange.java|org/geotools/referencefork/util/NumberRange.java|org/geotools/referencefork/util/Range.java|org/geotools/referencefork/util/MemberNameImpl.java|org/geotools/referencefork/util/NameFactory.java|org/geotools/referencefork/util/ObjectCaches.java|org/geotools/referencefork/util/package-info.java|org/geotools/referencefork/util/RangeSet.java|org/geotools/referencefork/util/RecordTypeImpl.java|org/geotools/referencefork/util/ScopedName.java|org/geotools/referencefork/metadata/iso/extent/BoundingPolygonImpl.java|org/geotools/referencefork/metadata/iso/extent/GeographicDescriptionImpl.java|org/geotools/referencefork/metadata/iso/extent/package-info.java|org/geotools/referencefork/metadata/iso/extent/SpatialTemporalExtentImpl.java|org/geotools/referencefork/metadata/iso/extent/TemporalExtentImpl.java|org/geotools/referencefork/metadata/iso/extent/VerticalExtentImpl.java|org/geotools/referencefork/metadata/iso/quality/AccuracyOfATimeMeasurementImpl.java|org/geotools/referencefork/metadata/iso/quality/CompletenessCommissionImpl.java|org/geotools/referencefork/metadata/iso/quality/CompletenessImpl.java|org/geotools/referencefork/metadata/iso/quality/CompletenessOmissionImpl.java|org/geotools/referencefork/metadata/iso/quality/ConceptualConsistencyImpl.java|org/geotools/referencefork/metadata/iso/quality/DataQualityImpl.java|org/geotools/referencefork/metadata/iso/quality/DomainConsistencyImpl.java|org/geotools/referencefork/metadata/iso/quality/FormatConsistencyImpl.java|org/geotools/referencefork/metadata/iso/quality/GriddedDataPositionalAccuracyImpl.java|org/geotools/referencefork/metadata/iso/quality/LogicalConsistencyImpl.java|org/geotools/referencefork/metadata/iso/quality/NonQuantitativeAttributeAccuracyImpl.java|org/geotools/referencefork/metadata/iso/quality/package-info.java|org/geotools/referencefork/metadata/iso/quality/QuantitativeAttributeAccuracyImpl.java|org/geotools/referencefork/metadata/iso/quality/RelativeInternalPositionalAccuracyImpl.java|org/geotools/referencefork/metadata/iso/quality/ScopeImpl.java|org/geotools/referencefork/metadata/iso/quality/TemporalAccuracyImpl.java|org/geotools/referencefork/metadata/iso/quality/TemporalConsistencyImpl.java|org/geotools/referencefork/metadata/iso/quality/TemporalValidityImpl.java|org/geotools/referencefork/metadata/iso/quality/ThematicAccuracyImpl.java|org/geotools/referencefork/metadata/iso/quality/ThematicClassificationCorrectnessImpl.java|org/geotools/referencefork/metadata/iso/quality/TopologicalConsistencyImpl.java|org/geotools/referencefork/referencing/operation/AbstractCoordinateOperationFactory.java|org/geotools/referencefork/referencing/operation/AuthorityBackedFactory.java|org/geotools/referencefork/referencing/operation/BufferedCoordinateOperationFactory.java|org/geotools/referencefork/referencing/operation/DefaultCoordinateOperationFactory.java|org/geotools/referencefork/referencing/operation/ProjectionAnalyzer.java|org/geotools/referencefork/referencing/factory/epsg/|org/geotools/referencefork/referencing/factory/wms/|org/geotools/referencefork/referencing/factory/AbstractAuthorityFactory.java|org/geotools/referencefork/referencing/factory/AbstractAuthorityMediator.java|org/geotools/referencefork/referencing/factory/AbstractCachedAuthorityFactory.java|org/geotools/referencefork/referencing/factory/AbstractEpsgMediator.java|org/geotools/referencefork/referencing/factory/AllAuthoritiesFactory.java|org/geotools/referencefork/referencing/factory/AuthorityFactoryAdapter.java|org/geotools/referencefork/referencing/factory/AuthorityFactoryProxy.java|org/geotools/referencefork/referencing/factory/BackingStoreException.java|org/geotools/referencefork/referencing/factory/BufferedAuthorityFactory.java|org/geotools/referencefork/referencing/factory/CachedAuthorityDecorator.java|org/geotools/referencefork/referencing/factory/CachedCRSAuthorityDecorator.java|org/geotools/referencefork/referencing/factory/DatumAliases.java|org/geotools/referencefork/referencing/factory/DeferredAuthorityFactory.java|org/geotools/referencefork/referencing/factory/FactoryDependencies.java|org/geotools/referencefork/referencing/factory/FactoryNotFoundException.java|org/geotools/referencefork/referencing/factory/FallbackAuthorityFactory.java|org/geotools/referencefork/referencing/factory/HTTP_AuthorityFactory.java|org/geotools/referencefork/referencing/factory/IdentifiedObjectFinder.java|org/geotools/referencefork/referencing/factory/IdentifiedObjectSet.java|org/geotools/referencefork/referencing/factory/ManyAuthoritiesFactory.java|org/geotools/referencefork/referencing/factory/OldReferencingObjectCache.java|org/geotools/referencefork/referencing/factory/OrderedAxisAuthorityFactory.java|org/geotools/referencefork/referencing/factory/PropertyAuthorityFactory.java|org/geotools/referencefork/referencing/factory/ReferencingObjectFactory.java|org/geotools/referencefork/referencing/factory/ThreadedAuthorityFactory.java|org/geotools/referencefork/referencing/factory/TransformedAuthorityFactory.java|org/geotools/referencefork/referencing/factory/URN_AuthorityFactory.java|org/geotools/referencefork/referencing/factory/URN_Parser.java|org/geotools/referencefork/referencing/factory/URN_Type.java|org/geotools/referencefork/referencing/Command.java|org/geotools/referencefork/referencing/operation/projection/AlbersEqualArea.java|org/geotools/referencefork/referencing/operation/projection/EquatorialOrthographic.java|org/geotools/referencefork/referencing/operation/projection/EquatorialStereographic.java|org/geotools/referencefork/referencing/operation/projection/EquidistantCylindrical.java|org/geotools/referencefork/referencing/operation/projection/HotineObliqueMercator.java|org/geotools/referencefork/referencing/operation/projection/Krovak.java|org/geotools/referencefork/referencing/operation/projection/LambertAzimuthalEqualArea.java|org/geotools/referencefork/referencing/operation/projection/LambertConformal.java|org/geotools/referencefork/referencing/operation/projection/LambertConformal1SP.java|org/geotools/referencefork/referencing/operation/projection/LambertConformal2SP.java|org/geotools/referencefork/referencing/operation/projection/LambertConformalBelgium.java|org/geotools/referencefork/referencing/operation/projection/LambertConformalESRI.java|org/geotools/referencefork/referencing/operation/projection/Mercator.java|org/geotools/referencefork/referencing/operation/projection/Mercator1SP.java|org/geotools/referencefork/referencing/operation/projection/Mercator2SP.java|org/geotools/referencefork/referencing/operation/projection/ModifiedParameterDescriptor.java|org/geotools/referencefork/referencing/operation/projection/NewZealandMapGrid.java|org/geotools/referencefork/referencing/operation/projection/ObliqueMercator.java|org/geotools/referencefork/referencing/operation/projection/ObliqueOrthographic.java|org/geotools/referencefork/referencing/operation/projection/ObliqueStereographic.java|org/geotools/referencefork/referencing/operation/projection/Orthographic.java|org/geotools/referencefork/referencing/operation/projection/PlateCarree.java|org/geotools/referencefork/referencing/operation/projection/PointOutsideEnvelopeException.java|org/geotools/referencefork/referencing/operation/projection/PolarOrthographic.java|org/geotools/referencefork/referencing/operation/projection/PolarStereographic.java|org/geotools/referencefork/referencing/operation/projection/Stereographic.java|org/geotools/referencefork/referencing/operation/projection/StereographicUSGS.java|org/geotools/referencefork/referencing/operation/projection/TransverseMercator.java|org/geotools/referencefork/referencing/factory/DirectAuthorityFactory.java|org/geotools/referencefork/referencing/DefaultAuthorityFactory.java|org/geotools/referencefork/geometry/GeometryBuilder.java|org/geotools/referencefork/metadata/iso/quality/QuantitativeResultImpl.java|org/geotools/referencefork/referencing/operation/DefaultConcatenatedOperation.java|org/geotools/referencefork/referencing/operation/DefaultPassThroughOperation.java|org/geotools/console/|org/geotools/referencefork/geometry/AbstractEnvelope.java|org/geotools/referencefork/geometry/Envelope2D.java|org/geotools/referencefork/geometry/Geometry.java|org/geotools/referencefork/geometry/GeometryFactoryFinder.java|org/geotools/referencefork/geometry/TransformedDirectPosition.java|org/geotools/referencefork/geometry/GeneralEnvelope.java|org/geotools/referencefork/referencing/operation/builder/GridParameters.java|org/geotools/referencefork/referencing/operation/builder/GridToEnvelopeMapper.java|org/geotools/referencefork/referencing/operation/builder/WarpGridBuilder.java|org/geotools/referencefork/referencing/operation/builder/WarpGridTester.java|org/geotools/referencefork/referencing/operation/builder/WarpGridBuilderTest.java|org/geotools/referencefork/referencing/operation/builder/InterpolationTest.java|org/geotools/referencefork/referencing/operation/builder/IDWGridBuilder.java|org/geotools/referencefork/referencing/operation/transform/ConcatenatedTransform.java|org/geotools/referencefork/referencing/operation/transform/ConcatenatedTransform1D.java|org/geotools/referencefork/referencing/operation/transform/ConcatenatedTransform2D.java|org/geotools/referencefork/referencing/operation/transform/ConcatenatedTransformDirect.java|org/geotools/referencefork/referencing/operation/transform/ConcatenatedTransformDirect1D.java|org/geotools/referencefork/referencing/operation/transform/ConcatenatedTransformDirect2D.java|org/geotools/referencefork/referencing/operation/transform/DimensionFilter.java|org/geotools/referencefork/referencing/operation/transform/NADCONTransform.java|org/geotools/referencefork/referencing/operation/transform/WarpGridTransform2D.java|org/geotools/referencefork/referencing/operation/transform/WarpAdapter.java|org/geotools/referencefork/referencing/operation/transform/WarpTransform2D.java|org/geotools/referencefork/referencing/operation/projection/MapProjection.java|org/geotools/referencefork/referencing/operation/projection/ProjectionException.java|org/geotools/referencefork/referencing/operation/builder/LocalizationGrid.java|org/geotools/referencefork/referencing/operation/builder/NADCONBuilder.java|org/geotools/referencefork/referencing/operation/builder/RSGridBuilder.java|org/geotools/referencefork/referencing/operation/builder/TPSGridBuilder.java|org/geotools/referencefork/referencing/operation/transform/LocalizationGrid.java" kind="src" path="src"/>
4
	<classpathentry kind="src" output="bin-test" path="src-test"/>
5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6
	<classpathentry kind="src" path="/libFMap"/>
7
	<classpathentry combineaccessrules="false" kind="src" path="/libIverUtiles"/>
8
	<classpathentry kind="src" path="/libGDBMS"/>
9
	<classpathentry kind="lib" path="/_fwAndami/lib/gvsig-i18n.jar" sourcepath="/libInternationalization/src"/>
10
	<classpathentry kind="src" path="/libProjection"/>
11
	<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.8.jar"/>
12
	<classpathentry kind="lib" path="/_fwAndami/lib/castor-0.9.5.3-xml.jar"/>
13
	<classpathentry kind="lib" path="/_fwAndami/lib/org.gvsig.exceptions.jar"/>
14
	<classpathentry kind="lib" path="/libFMap/lib/driver-manager-1.1.jar" sourcepath="/libDriverManager"/>
15
	<classpathentry kind="lib" path="lib/jump-api-1.2-alpha4.jar"/>
16
	<classpathentry kind="lib" path="lib/jump-workbench.jar"/>
17
	<classpathentry kind="lib" path="lib/jcommon-0.8.4.jar"/>
18
	<classpathentry kind="lib" path="lib/jfreechart-0.9.9.jar"/>
19
	<classpathentry kind="lib" path="lib/roadmatcher-1.4.jar"/>
20
	<classpathentry kind="lib" path="/libFMap/lib/units-0.01.jar"/>
21
	<classpathentry kind="lib" path="/libFMap/lib/geoapi-2.0.jar"/>
22
	<classpathentry combineaccessrules="false" kind="src" path="/appgvSIG"/>
23
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
24
	<classpathentry kind="lib" path="lib/jai_core.jar"/>
25
	<classpathentry kind="lib" path="/libFMap/lib/vecmath-1.3.jar"/>
26
	<classpathentry kind="lib" path="/libFMap/lib/jts-1.9.jar"/>
27
	<classpathentry kind="lib" path="/libFMap/lib/geoutils.jar"/>
28
	<classpathentry kind="output" path="bin"/>
29
</classpath>
0 30

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/jts/LineStringSplitter.java
1
package org.gvsig.jts;
2

  
3
import com.vividsolutions.jts.geom.LineString;
4

  
5
public class LineStringSplitter {
6
 
7
	public static LineString[] split(LineString lineString) {
8
		return null;
9
	}
10
	 
11
}
12
 
0 13

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/TopologyError.java
1
package org.gvsig.topology;
2

  
3
import com.iver.cit.gvsig.fmap.core.IFeature;
4

  
5

  
6
/**
7
 *Error produced when one or many features ?
8
 *violates a topology rule.
9
 */
10
public class TopologyError implements IFeature {
11
 
12
	/**
13
	 *rule which has been violated
14
	 */
15
	private AbstractTopologyRule violatedRule;
16
	 
17
	/**
18
	 *features of the source layer that
19
	 *violates the rule (if the rule is a self-rule,
20
	 *the error will only have source layer features)
21
	 */
22
	private IFeature[] sourceLyrFeatures;
23
	 
24
	/**
25
	 *features of the destination layer
26
	 *that violate the rule (only in rules between
27
	 *two layers)
28
	 */
29
	private IFeature[] destinationLyrFeatures;
30
	 
31
	private boolean exception;
32
	 
33
	public void setViolatedRule(AbstractTopologyRule violatedRule) {
34
	}
35
	 
36
	public AbstractTopologyRule getViolatedRule() {
37
		return null;
38
	}
39
	 
40
	public void setSourceLyrFeatures(IFeature[] sourceLyrFeatures) {
41
	}
42
	 
43
	public IFeature[] getSourceLyrFeatures() {
44
		return null;
45
	}
46
	 
47
	public void setDestinationLyrFeatures(IFeature[] destinationLyrFeatures) {
48
	}
49
	 
50
	public IFeature[] getDestinationLyrFeatures() {
51
		return null;
52
	}
53
	 
54
	/**
55
	 *Ruturns the type of geometry of the error
56
	 */
57
	public int getShapeType() {
58
		return 0;
59
	}
60
	 
61
	public void setException(boolean exception) {
62
	}
63
	 
64
	public boolean isException() {
65
		return false;
66
	}
67
	 
68
}
69
 
0 70

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/LinesMustNotHavePseudonodes.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.AbstractTopologyRule;
4
import org.gvsig.topology.IOneLyrRule;
5

  
6

  
7
/**
8
 *This rule checks that lines of a line layer dont have
9
 *pseudonodes ends (a point that only touch another line)
10
 */
11
public class LinesMustNotHavePseudonodes extends AbstractTopologyRule implements IOneLyrRule {
12
 
13
}
14
 
0 15

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/LineMustNotHaveDangles.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.AbstractTopologyRule;
4
import org.gvsig.topology.IOneLyrRule;
5

  
6

  
7
/**
8
 *All end points of a line must touch at least another line.
9
 *(if only touch one line, its a pseudonode, not a dangle)
10
 *This rule is checked for the two ends of a line.
11
 *
12
 */
13
public class LineMustNotHaveDangles extends AbstractTopologyRule implements IOneLyrRule {
14
 
15
}
16
 
0 17

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/MustNotHaveRepeatedPoints.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.AbstractTopologyRule;
4
import org.gvsig.topology.IOneLyrRule;
5

  
6

  
7
/**
8
 *This rule checks that a geometry (line or polygon)
9
 *dont have consecutive repeated points)
10
 *
11
 */
12
public class MustNotHaveRepeatedPoints extends AbstractTopologyRule implements IOneLyrRule {
13
 
14
}
15
 
0 16

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/MustBeLargerThanClusterTolerance.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.IOneLyrRule;
4
import org.gvsig.topology.AbstractTopologyRule;
5
import org.gvsig.topology.Topology;
6

  
7

  
8
/**
9
 *For lines o polygons. The lenght of a line or the perimeter
10
 *of a polygon must be larger than the cluster tolerance
11
 *
12
 */
13
public class MustBeLargerThanClusterTolerance extends AbstractTopologyRule implements IOneLyrRule {
14
 
15
	private Topology topology;
16
	 
17
}
18
 
0 19

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/JtsValidRule.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.AbstractTopologyRule;
4
import org.gvsig.topology.IOneLyrRule;
5

  
6

  
7
/**
8
 *Any validated geometry must be a right JTS geometry.
9
 */
10
public class JtsValidRule extends AbstractTopologyRule implements IOneLyrRule {
11
 
12
}
13
 
0 14

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/LineMustNotSelfIntersect.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.AbstractTopologyRule;
4
import org.gvsig.topology.IOneLyrRule;
5

  
6

  
7
/**
8
 *Lines of a layer must not have self intersections.
9
 *JTS allows this. This is one of the restrictions that must
10
 *not have pseudonodos checks.
11
 *
12
 */
13
public class LineMustNotSelfIntersect extends AbstractTopologyRule implements IOneLyrRule {
14
 
15
}
16
 
0 17

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/PolygonMustNotSelfIntersect.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.AbstractTopologyRule;
4
import org.gvsig.topology.IOneLyrRule;
5

  
6

  
7
/**
8
 *The polygons of a layer must not have self intersections
9
 *
10
 */
11
public class PolygonMustNotSelfIntersect extends AbstractTopologyRule implements IOneLyrRule {
12
 
13
}
14
 
0 15

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/topologyrules/PolygonsMustNotOverlap.java
1
package org.gvsig.topology.topologyrules;
2

  
3
import org.gvsig.topology.AbstractTopologyRule;
4
import org.gvsig.topology.IOneLyrRule;
5

  
6

  
7
/**
8
 *The polygons of a given layer must not overlaps
9
 *each other (their intersection must be a line, not an area)
10
 *
11
 */
12
public class PolygonsMustNotOverlap extends AbstractTopologyRule implements IOneLyrRule {
13
 
14
}
15
 
0 16

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/AbstractTopologyRule.java
1
package org.gvsig.topology;
2

  
3
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
4
import com.iver.cit.gvsig.fmap.core.IFeature;
5
import java.awt.geom.Rectangle2D;
6
import java.util.Collection;
7

  
8
public abstract class AbstractTopologyRule implements ITopologyRule {
9
 
10
	private FLyrVect originLyr;
11
	 
12
	private FLyrVect destinationLyr;
13
	 
14
	private Topology topology;
15
	 
16
	public void setOriginLyr(FLyrVect originLyr) {
17
	}
18
	 
19
	public FLyrVect getOriginLyr() {
20
		return null;
21
	}
22
	 
23
	public void setDestinationLyr(FLyrVect destinationLyr) {
24
	}
25
	 
26
	public FLyrVect getDestinationLyr() {
27
		return null;
28
	}
29
	 
30
	public String getName() {
31
		return null;
32
	}
33
	 
34
	/**
35
	 *Checks if the rule's parameters 
36
	 *(sourceLyr, destinationLyr) verify 
37
	 *rule preconditions (geometry type, etc.)
38
	 */
39
	public void checkPreconditions() {
40
	}
41
	 
42
	public void checkRule() {
43
	}
44
	 
45
	void validateFeature(IFeature feature) {
46
	}
47
	 
48
	public void checkRule(Rectangle2D rect) {
49
	}
50
	 
51
	public Collection getTopologyErrors() {
52
		return null;
53
	}
54
	 
55
}
56
 
0 57

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/IOneLyrRule.java
1
package org.gvsig.topology;
2

  
3

  
4
/**
5
 *Marker interface for all rules that applies to only one layer
6
 *
7
 */
8
public interface IOneLyrRule extends ITopologyRule {
9
 
10
}
11
 
0 12

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/ITopologyStatus.java
1
package org.gvsig.topology;
2

  
3
public interface ITopologyStatus {
4
 
5
	public static final byte VALIDATED = 0;
6
	 
7
	public static final byte VALIDATED_WITH_ERRORS = 1;
8
	 
9
	public static final byte NON_VALIDATED = 2;
10
	 
11
}
12
 
0 13

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/Topology.java
1
package org.gvsig.topology;
2

  
3
import com.iver.cit.gvsig.fmap.layers.FLayers;
4
import com.vividsolutions.jts.geom.Envelope;
5
import java.awt.geom.Rectangle2D;
6
import org.gvsig.topology.topologyrules.MustBeLargerThanClusterTolerance;
7
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
8

  
9
public class Topology extends FLayers implements ITopologyErrorContainer, ITopologyStatus {
10
 
11
	private double clusterTolerance;
12
	 
13
	private int status;
14
	 
15
	/**
16
	 *If during validation process a topoly
17
	 *exceeds this parameters, validation will be stopped.
18
	 *
19
	 */
20
	private int maxNumberOfErrors = -1;
21
	 
22
	private AbstractTopologyRule[] abstractTopologyRule;
23
	 
24
	private Envelope[] envelope;
25
	 
26
	private Rectangle2D[] dirtyZones;
27
	 
28
	private MustBeLargerThanClusterTolerance[] clusterTolRule;
29
	 
30
	public double getClusterTolerance() {
31
		return 0;
32
	}
33
	 
34
	/**
35
	 *Adds a new topology rule to the topology.
36
	 */
37
	public void addRule(AbstractTopologyRule rule) {
38
	}
39
	 
40
	/**
41
	 *Adds a layer to the topology. If the topology has been validated, changes
42
	 *topology status to NON-VALIDATED and adds a dirty zone equals to
43
	 *the layer extent.
44
	 */
45
	public void addLayer(FLyrVect layer, int xyRank, int zRank) {
46
	}
47
	 
48
	public void setStatus(int status) {
49
	}
50
	 
51
	public int getStatus() {
52
		return 0;
53
	}
54
	 
55
	/**
56
	 *Adds a dirty zone to the topology
57
	 *(usually whe a feature of a layer
58
	 *of the topology has been edited)
59
	 */
60
	public void addDirtyZone(Rectangle2D dirtyZone) {
61
	}
62
	 
63
	public Rectangle2D getDirtyZone() {
64
		return null;
65
	}
66
	 
67
	public void validate() {
68
	}
69
	 
70
	public int getLayerCount() {
71
		return 0;
72
	}
73
	 
74
	public int getRuleCount() {
75
		return 0;
76
	}
77
	 
78
	public FLyrVect getLyr(int lyrIndex) {
79
		return null;
80
	}
81
	 
82
	public AbstractTopologyRule getRule(int ruleIndex) {
83
		return null;
84
	}
85
	 
86
	/**
87
	 *Returns if a specified rectangle touch one
88
	 *of the existing dirty zones. If not, probably
89
	 *is needed to add to the dirty zones collection.
90
	 *If true, maybe it could modify the dirty zone.
91
	 */
92
	public boolean isInDirtyZone() {
93
		return false;
94
	}
95
	 
96
	/**
97
	 *Modify the dirty zone of the specified index
98
	 */
99
	public void updateDirtyZone(int dirtyZoneIndex, Rectangle2D dirtyZone) {
100
	}
101
	 
102
	public void setMaxNumberOfErrors(int maxNumberOfErrors) {
103
	}
104
	 
105
	public int getMaxNumberOfErrors() {
106
		return 0;
107
	}
108
	 
109
}
110
 
0 111

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/ITopologyRule.java
1
package org.gvsig.topology;
2

  
3
public interface ITopologyRule {
4
 
5
}
6
 
0 7

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/TopologyPersister.java
1
package org.gvsig.topology;
2

  
3
import java.util.Map;
4

  
5

  
6
/**
7
 *Class with the responsability of persist topologies
8
 *and their elements.
9
 */
10
public class TopologyPersister {
11
 
12
	public static void persist(Topology topology) {
13
	}
14
	 
15
	public static Topology load(Map storeParams) {
16
		return null;
17
	}
18
	 
19
}
20
 
0 21

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/ITwoLyrRule.java
1
package org.gvsig.topology;
2

  
3

  
4
/**
5
 *Marker interface for all rules that applies to two layers
6
 */
7
public interface ITwoLyrRule extends ITopologyRule {
8
 
9
}
10
 
0 11

  
tags/v1_11_0_Build_1306/libraries/libTopology/uml-jude/org/gvsig/topology/ITopologyErrorContainer.java
1
package org.gvsig.topology;
2

  
3
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
4
import org.cresques.cts.IProjection;
5

  
6

  
7
/**
8
 *All the classes that contains TopologyError must 
9
 *implement this interface.
10
 */
11
public interface ITopologyErrorContainer {
12
 
13
	public static final int ONLY_ERRORS = 0;
14
	 
15
	public static final int ONLY_EXCEPTIONS = 1;
16
	 
17
	public static final int BOTH_ERROR_EXCEPTIONS = 2;
18
	 
19
	public void addTopologyError(TopologyError topologyError);
20
	/**
21
	 *Returns the errors contained. In function
22
	 *of the specified params, returned errors 
23
	 *will be reprojected, filtered by rule, geometry type,
24
	 *etc.
25
	 */
26
	public TopologyError[] getTopologyErrors(String ruleName, int shapeType, FLyrVect sourceLayer, IProjection desiredProjection, int includeExceptions);
27
	/**
28
	 *Marks the specified feature as the
29
	 *specified status (exception or not exception)
30
	 */
31
	public void markAsTopologyException(TopologyError topologyError, boolean markAsException);
32
}
33
 
0 34

  
tags/v1_11_0_Build_1306/libraries/libTopology/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>libTopology</name>
4
	<comment>@key 32303036313030362D31303030206C6962546F706F6C6F67792F416C7661726F205A6162616C61 </comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>com.omondo.uml.std.Builder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jdt.core.javanature</nature>
21
		<nature>com.omondo.uml.std.Nature</nature>
22
	</natures>
23
</projectDescription>
0 24

  
tags/v1_11_0_Build_1306/libraries/libTopology/src-test/org/gvsig/topology/TopologyTest.java
1
/*
2
 * Created on 24-sep-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id$
47
* $Log$
48
*
49
*/
50
package org.gvsig.topology;
51

  
52
import java.io.File;
53
import java.net.URL;
54
import java.util.HashMap;
55
import java.util.List;
56
import java.util.Map;
57

  
58
import junit.framework.TestCase;
59

  
60
import org.cresques.cts.IProjection;
61
import org.gvsig.topology.topologyrules.MustBeLargerThanClusterTolerance;
62
import org.gvsig.topology.topologyrules.MustNotHaveRepeatedPoints;
63
import org.gvsig.topology.topologyrules.jtsisvalidrules.GeometryMustHaveValidCoordinates;
64
import org.gvsig.topology.util.LayerFactory;
65

  
66
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
67
import com.iver.cit.gvsig.fmap.MapContext;
68
import com.iver.cit.gvsig.fmap.ViewPort;
69
import com.iver.cit.gvsig.fmap.core.FShape;
70
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
71
import com.iver.cit.gvsig.fmap.layers.FLayer;
72
import com.iver.cit.gvsig.fmap.layers.FLayers;
73
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
74

  
75
/**
76
 * Unit tests for Topology class.
77
 * 
78
 * @author azabala
79
 *
80
 */
81
public class TopologyTest extends TestCase {
82
	File baseDataPath;
83
	
84
	File baseDriversPath;
85
	
86
	IProjection PROJECTION_DEFAULT;
87
	
88
	ViewPort VIEWPORT;
89
	
90
	FLayers ROOT;
91
	
92
	SimpleTopologyErrorContainer errorContainer;
93
	
94
	Topology topology = null;
95
	
96
	Topology topology2 = null;
97
	
98
	FLyrVect multiPointLayer;
99
	
100
	FLyrVect lineLyrWithCollapsedCoords;
101
	
102
	FLyrVect shapeBasedLinearLyr;
103
	
104
	MapContext mapContext;
105
	
106
	
107
	public void setUp() throws Exception{
108
		super.setUp();
109
		URL url = TopologyTest.class.getResource("testdata");
110
		if (url == null)
111
			throw new Exception("No se encuentra el directorio con datos de prueba");
112

  
113
		baseDataPath = new File(url.getFile());
114
		if (!baseDataPath.exists())
115
			throw new Exception("No se encuentra el directorio con datos de prueba");
116

  
117
		baseDriversPath = new File("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
118
		if (!baseDriversPath.exists())
119
			throw new Exception("Can't find drivers path " );
120

  
121
		com.iver.cit.gvsig.fmap.layers.LayerFactory.setDriversPath(baseDriversPath.getAbsolutePath());
122
		
123
		
124
		PROJECTION_DEFAULT = CRSFactory.getCRS("EPSG:23030");
125
		VIEWPORT = new ViewPort(PROJECTION_DEFAULT);
126
		mapContext = new MapContext(VIEWPORT);
127
		ROOT = mapContext.getLayers();
128
		errorContainer = new SimpleTopologyErrorContainer();
129
		
130
		topology = new Topology(mapContext, ROOT, 0.01, 1000, errorContainer );
131
		topology2 = new Topology(mapContext, ROOT, 0.01, 1000, errorContainer);
132
		
133
		
134
		multiPointLayer = LayerFactory.getLyrWithRepeatedCoords();
135
		lineLyrWithCollapsedCoords = LayerFactory.getLineLayerWithCollapsedCoords();
136
		shapeBasedLinearLyr = (FLyrVect) newLayer("vc1-1500.shp", "gvSIG shp driver");
137
	}
138
	
139
	public void tearDown() throws Exception{
140
		super.tearDown();
141
		topology = null;
142
		topology2 = null;
143
		multiPointLayer = null;
144
		lineLyrWithCollapsedCoords = null;
145
	}
146
	
147
	public  FLayer newLayer(String fileName,
148
			   String driverName)
149
		throws LoadLayerException {
150
		FLayer solution = null;	
151
		File file = new File(baseDataPath, fileName);
152
		solution = com.iver.cit.gvsig.fmap.layers.LayerFactory.createLayer(fileName,
153
								driverName,
154
								file, PROJECTION_DEFAULT);
155
		solution.setAvailable(true);
156
		return solution;
157
			
158
}
159
	
160
	/*
161
	 * To test in a Topology:
162
	 * 
163
	 * 1. If we change cluster tolerance, status must be reset:
164
	 *  -NON_VALIDATED.
165
	 *  -Dirty zones clear.
166
	 *  -Topology error clear.
167
	 *  -Cluster tolerance rules updated with new cluster tolerance
168
	 *  
169
	 *  
170
	 *  
171
	 *  2. If number of errors is greater than max number of errors during
172
	 *  a topology validation, process will be interrupted.
173
	 *  
174
	 *  3. We cant add rules with layers not referenced by the topology.
175
	 *  
176
	 *  4. deleted.
177
	 *  
178
	 *  5. If we add a new layer to a topology with status VALIDATED, new status
179
	 *  will be VALIDATED_WITH_DIRTY_ZONES, and a new dirty zone for the layer
180
	 *  full extent will be created. If layer shape type is POINT or MULTIPOINT,
181
	 *  status will be VALIDATED, because this kind of layer dont have MustBeGreaterThanClusterTolerance
182
	 *  rule associated.
183
	 *  
184
	 
185
	 TEST 6 NOT IMPLEMENTED YET
186
	 *  6. If a feature's geometry of a topology's layer is edited, a new dirty
187
	 *  zone will be create for its bounds:
188
	 *     -with the exception if topology status would be NON_VALIDATED.
189
	
190
	
191
	 *  7. If we validate a topology with status NON_VALIDATED, and it finds errors,
192
	 *  new status will be VALIDATED_WITH_ERRORS. 
193
	 *  If it doesnt find errors, status wll be VALIDATED.
194
	 *  
195
	 *  8. If two errors are in the same dirty zone, they dont add new dirty
196
	 *  zones.
197
	   
198
	 
199
	 *  9. If a topology error is added to a topology, dirty zones will be
200
	 *  updated (with the exception if topology error'geometry bounds is in an existent dirty zone)
201
	 *  
202
	 *  10. If we mark a topology exception as an exception, it will be removed
203
	 *  from dirty zones. If the number of exceptions is equal to the number of
204
	 *  errors, new status will be VALIDATED.
205
	 *  
206
	 *  11. If we demote a error from exception to error, it will be added to
207
	 *  dirty zones. If number of errors is superior to number of exceptions,
208
	 *  new status will be VALIDATED_WITH_ERRORS.
209
	 *  
210
	 *  TEST 12 NOT IMPLEMENTED YET
211
	 *  12. We must filter topology errors by rule, layer, geometry type, etc.
212
	 *  
213
	 * */
214
	public void testStatusAndCoherence() throws Exception{
215
		
216
		//first test: cluster tolerance 0.1d, not collapsed geometries
217
		topology.addLayer(lineLyrWithCollapsedCoords);
218
		topology.validate();
219
		int status = topology.getStatus();
220
		assertTrue(status == Topology.VALIDATED);
221
		int numberOfErrors = topology.getNumberOfErrors();
222
		assertTrue(numberOfErrors == 0);
223
		
224
		//second test: cluster tolerance 12d, one topology error
225
		topology.setClusterTolerance(12d);
226
		topology.validate();
227
		status = topology.getStatus();
228
		assertTrue(status == Topology.VALIDATED_WITH_ERRORS);
229
		numberOfErrors = topology.getNumberOfErrors();
230
		assertTrue(numberOfErrors == 1);
231
		TopologyError error = topology.getTopologyError(0);
232
		assertTrue(error.getViolatedRule().getClass().equals(MustBeLargerThanClusterTolerance.class));
233
		
234
		
235
		//third test: we add a point layer with repeated points
236
		topology.addLayer(multiPointLayer);
237
		MustNotHaveRepeatedPoints rule1 = 
238
			new MustNotHaveRepeatedPoints(multiPointLayer);
239
		topology.addRule(rule1);
240
		status = topology.getStatus();
241
		assertTrue(status == Topology.NOT_VALIDATED);
242
		int numberOfDirtyZones = topology.getNumberOfDirtyZones();
243
		assertTrue(numberOfDirtyZones == 0);
244
		
245
		topology.validate();
246
		status = topology.getStatus();
247
		assertTrue(status == Topology.VALIDATED_WITH_ERRORS);
248
		numberOfErrors = topology.getNumberOfErrors();
249
		assertTrue(numberOfErrors == 2);
250
		
251
		topology.resetStatus();
252
		topology.setMaxNumberOfErrors(1);
253
		topology.validate();
254
		assertTrue(topology.getNumberOfErrors() == 1);
255
		topology.resetStatus();
256
		topology.setMaxNumberOfErrors(1000);
257
		topology.validate();
258
		assertTrue(topology.getNumberOfErrors() == 2);
259
		
260
		//mark as exception
261
		for(int i = 0; i < numberOfErrors; i++){
262
			error = topology.getTopologyError(i);
263
			topology.markAsTopologyException(error);
264
		}
265
		assertTrue(topology.getStatus() == Topology.VALIDATED);
266

  
267
	}
268
	
269
	
270
	public void testAddRuleWithLayersNotReferenced(){
271
		MustNotHaveRepeatedPoints rule = 
272
			new MustNotHaveRepeatedPoints(multiPointLayer);
273
		boolean ok = false;
274
		try {
275
			topology2.addRule(rule);
276
			ok = true;
277
		} catch (RuleNotAllowedException e) {
278
			// TODO Auto-generated catch block
279
			e.printStackTrace();
280
		} catch (TopologyRuleDefinitionException e) {
281
			// TODO Auto-generated catch block
282
			e.printStackTrace();
283
		}
284
		assertTrue(!ok);
285
	}
286
	
287
	public void testDemoteExceptionsToErrors() throws RuleNotAllowedException, TopologyRuleDefinitionException{
288
		topology2.setClusterTolerance(12d);
289
		topology2.addLayer(multiPointLayer);
290
		topology2.addLayer(this.lineLyrWithCollapsedCoords);
291
		topology2.addRule(new MustNotHaveRepeatedPoints(multiPointLayer));
292
		
293
		topology2.validate();
294
		int numberOfErrors = topology2.getNumberOfErrors();
295
		assertTrue(numberOfErrors == 2);
296
		for(int i = 0; i < numberOfErrors; i++){
297
			TopologyError error = topology2.getTopologyError(i);
298
			topology2.markAsTopologyException(error);
299
		}
300
		assertTrue(topology2.getStatus() == Topology.VALIDATED);
301
		for(int i = 0; i < numberOfErrors; i++){
302
			TopologyError error = topology2.getTopologyError(i);
303
			topology2.demoteToError(error);
304
		}
305
		assertTrue(topology2.getStatus() == Topology.VALIDATED_WITH_ERRORS);
306
		
307
		//At this point, topology have two topologyerrors (MustNotHaveRepeatedPoints and MustBeGreaterThanClusterTolerance
308
		//shape types are LINE (FPolyline2D) and Point (FMultiPoint2D).
309
		List<TopologyError> errorList = topology2.getTopologyErrorsByLyr(lineLyrWithCollapsedCoords, null, true);
310
		assertTrue(errorList.size() == 1);
311
		
312
		errorList = topology.getTopologyErrorsByShapeType(FShape.LINE, null, true);
313
		assertTrue(errorList.size() == 1);
314
		
315
		
316
	}
317
	
318
	public void testTopologyPersistence() throws RuleNotAllowedException, TopologyRuleDefinitionException{
319
		topology2 = new Topology(mapContext, ROOT, 0.01, 1000, errorContainer);
320
		topology2.addLayer(this.shapeBasedLinearLyr);
321
		MustNotHaveRepeatedPoints ruleA = new MustNotHaveRepeatedPoints(topology2, shapeBasedLinearLyr);
322
		topology2.addRule(ruleA);
323
		GeometryMustHaveValidCoordinates ruleB = new 
324
			GeometryMustHaveValidCoordinates(topology2, shapeBasedLinearLyr);
325
		topology2.addRule(ruleB);
326
		
327
		String fileToSave1 = "/testTopology.xml";
328
		Map<String, Object> storageParams = new HashMap<String, Object>();
329
		storageParams.put(TopologyPersister.FILE_PARAM_NAME, fileToSave1);
330
		TopologyPersister.persist(topology2, storageParams);
331
		Topology topologyA = TopologyPersister.load(mapContext, storageParams);
332
		
333
		assertTrue(topology2.getRuleCount() == topologyA.getRuleCount());
334
		assertTrue(topology2.getLayerCount() == topologyA.getLayerCount());
335
	}
336
	
337
}
338

  
tags/v1_11_0_Build_1306/libraries/libTopology/src-test/org/gvsig/topology/util/LayerFactory.java
1
/*
2
 * Created on 24-sep-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id$
47
* $Log$
48
*
49
*/
50
package org.gvsig.topology.util;
51

  
52
import java.util.ArrayList;
53
import java.util.List;
54

  
55
import org.gvsig.fmap.core.NewFConverter;
56

  
57
import com.hardcode.gdbms.engine.values.StringValue;
58
import com.hardcode.gdbms.engine.values.Value;
59
import com.hardcode.gdbms.engine.values.ValueFactory;
60
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
61
import com.iver.cit.gvsig.fmap.core.FMultiPoint2D;
62
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
63
import com.iver.cit.gvsig.fmap.core.FShape;
64
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
65
import com.iver.cit.gvsig.fmap.core.IFeature;
66
import com.iver.cit.gvsig.fmap.core.IGeometry;
67
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
68
import com.iver.cit.gvsig.fmap.drivers.FeatureCollectionMemoryDriver;
69
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
70
import com.iver.cit.gvsig.fmap.drivers.LayerDefinition;
71
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
72
import com.vividsolutions.jts.geom.Coordinate;
73
import com.vividsolutions.jts.geom.Geometry;
74
import com.vividsolutions.jts.geom.GeometryFactory;
75
import com.vividsolutions.jts.geom.MultiPoint;
76
import com.vividsolutions.jts.geom.Point;
77
import com.vividsolutions.jts.geom.PrecisionModel;
78
import com.vividsolutions.jts.io.ParseException;
79
import com.vividsolutions.jts.io.WKTReader;
80

  
81
public class LayerFactory {
82
	static PrecisionModel pm = new PrecisionModel(10000);
83
	static GeometryFactory factory = new GeometryFactory(pm);
84
	static WKTReader wktReader = new WKTReader(factory);
85
	
86
	
87
	public static FLyrVect getLineLayerWithCollapsedCoords() throws ParseException{
88
		Geometry ln1 = wktReader.read("LINESTRING(500 500, 510 500)");
89
		Geometry ln2 = wktReader.read("LINESTRING(700 100, 720 120, 800 600)");
90
		
91
		LayerDefinition definition = createTestLayerDefinition();
92
		definition.setShapeType(FShape.LINE);
93
		
94
		//feature 1
95
		int index = 0;
96
		IFeature f1 = createTestFeature(ln1, index);
97
		index++;
98
		IFeature f2 = createTestFeature(ln2, index);
99
		
100
		ArrayList<IFeature> features = new ArrayList<IFeature>();
101
		features.add(f1);
102
		features.add(f2);
103
		
104
		FeatureCollectionMemoryDriver driver = 
105
			new FeatureCollectionMemoryDriver("multipuntos", 
106
				                                   features,
107
				                                   definition);
108
		
109
		return  (FLyrVect) com.iver.cit.gvsig.fmap.layers.LayerFactory.createLayer("multipuntos",
110
																driver, 
111
																null);
112
	}
113
	
114
	public static FLyrVect getLyrWithRepeatedCoords() throws ParseException{	
115
		Geometry multiPoint = wktReader.read("MULTIPOINT (520 160, 540 180, 540 180, 540 180, 600 180, 580 140, 640 140, 640 140, 640 160)");
116
		Geometry multiPoint2 = wktReader.read("MULTIPOINT (520 160, 540 180, 600 180, 580 140, 640 140,  640 160)");
117
		LayerDefinition definition = createTestLayerDefinition();
118
		definition.setShapeType(FShape.MULTIPOINT);
119
		
120
		Coordinate[] coords = ((MultiPoint)multiPoint).getCoordinates();
121
		double[] x = new double[coords.length];
122
		double[] y = new double[coords.length];
123
		for(int i = 0; i < coords.length; i++){
124
			x[i] = coords[i].x;
125
			y[i] = coords[i].y;
126
		}
127
		FMultiPoint2D m1 = new FMultiPoint2D(x, y);
128
		StringValue value = ValueFactory.createValue("s1");
129
		Value[] values = {value};
130
		DefaultFeature f1 = new DefaultFeature(m1, values, "id1");
131
		
132
		Coordinate[] coords2 = ((MultiPoint)multiPoint2).getCoordinates();
133
		double[] x2 = new double[coords2.length];
134
		double[] y2 = new double[coords2.length];
135
		for(int i = 0; i < coords2.length; i++){
136
			x2[i] = coords2[i].x;
137
			y2[i] = coords2[i].y;
138
		}
139
		FMultiPoint2D m2 = new FMultiPoint2D(x2, y2);
140
		StringValue value2 = ValueFactory.createValue("s2");
141
		Value[] values2 = {value2};
142
		DefaultFeature f2 = new DefaultFeature(m2, values2, "id2");
143
		
144
		ArrayList<IFeature> features = new ArrayList<IFeature>();
145
		features.add(f1);
146
		features.add(f2);
147
		
148
		
149
		FeatureCollectionMemoryDriver driver = 
150
			new FeatureCollectionMemoryDriver("multipuntos", 
151
				                                   features,
152
				                                   definition);
153
		
154
		return  (FLyrVect) com.iver.cit.gvsig.fmap.layers.LayerFactory.createLayer("multipuntos",
155
																driver, 
156
																null);
157
	}
158
	
159
	public static FLyrVect createPointLyrWhichDontPasJtsValidRule(){
160
		LayerDefinition definition = createTestLayerDefinition();
161
		definition.setShapeType(FShape.POINT);
162
		FeatureCollectionMemoryDriver driver = null;
163
		
164
		Coordinate coord1 = new Coordinate(Double.NaN, Double.POSITIVE_INFINITY);
165
		Point pt1 = factory.createPoint(coord1);
166
		int index = 0;
167
		IFeature f1 = createTestFeature(pt1, index);
168
		index++;
169
		
170
		Coordinate coord2 = new Coordinate(100d, 100d);
171
		Point pt2 = factory.createPoint(coord2);
172
		IFeature f2 = createTestFeature(pt2, index);
173
		index++;
174
		
175
		Coordinate coord3 = new Coordinate(50d, 75d);
176
		Point pt3 = factory.createPoint(coord3);
177
		IFeature f3 = createTestFeature(pt3, index);
178
		index++;
179
		
180
		Coordinate coord4 = new Coordinate(Double.NaN, Double.NEGATIVE_INFINITY);
181
		Point pt4 = factory.createPoint(coord4);
182
		IFeature f4 = createTestFeature(pt4, index);
183
		index++;
184
		
185
		List<IFeature> features = new ArrayList<IFeature>();
186
		features.add(f1);
187
		features.add(f2);
188
		features.add(f3);
189
		features.add(f4);
190
		
191
		driver = new FeatureCollectionMemoryDriver("puntos no validos jts",
192
															features,
193
															definition);
194
		
195
		return  (FLyrVect) com.iver.cit.gvsig.fmap.layers.LayerFactory.createLayer("puntosJtsInvalidos",
196
								driver, 
197
								null);
198
	}
199
	
200
	
201
	public static FLyrVect createLineLyrWhichDontPasJtsValidRule(){
202
		LayerDefinition definition = createTestLayerDefinition();
203
		definition.setShapeType(FShape.LINE);
204
		FeatureCollectionMemoryDriver driver = null;
205
		
206
		Coordinate coord1 = new Coordinate(100d, 230.342d);
207
		Coordinate[] coords = {coord1, coord1};
208
		Geometry geom1 = factory.createLineString(coords);
209
		int index = 0;
210
		IFeature f1 = createTestFeature(geom1, index);
211
		
212
		Coordinate coord2 = new Coordinate(139d, 2021.0d);
213
		Coordinate[] coords2 = {coord1, coord2};
214
		Geometry geom2 = factory.createLineString(coords2);
215
		IFeature f2 = createTestFeature(geom2, index);
216
		
217
		Coordinate coord3 = new Coordinate(212d, Double.NaN);
218
		Coordinate[] coords3 = {coord2, coord3};
219
		Geometry geom3 = factory.createLineString(coords3);
220
		IFeature f3 = createTestFeature(geom3, index);
221
		
222
		List<IFeature> features = new ArrayList<IFeature>();
223
		features.add(f1);
224
		features.add(f2);
225
		features.add(f3);
226
		
227
		driver = new FeatureCollectionMemoryDriver("lineas no validos jts",
228
				features,
229
				definition);
230

  
231
		return  (FLyrVect) com.iver.cit.gvsig.fmap.layers.LayerFactory.
232
			createLayer("puntosJtsInvalidos",
233
							driver, 
234
							null);
235
	}
236

  
237
	//TODO Create test cases to probe SNAP functions
238
	public static FLyrVect createPolygonLayerWhichDontPassJtsValidRule() throws ParseException{
239
		LayerDefinition definition = createTestLayerDefinition();
240
		definition.setShapeType(FShape.POLYGON);
241
		FeatureCollectionMemoryDriver driver = null;
242
		List<IFeature> features = new ArrayList<IFeature>();
243
		int index = 0;
244
		
245
		//A polygon with a hole which shell has a self-intersection->TODO el paso jts->fmap->jts hace cosas raras
246
		Geometry pol1 = wktReader.read("POLYGON ((80 140, 360 60, 180 340, 200 60, 240 20, 80 140), (220 200, 220 140, 300 100, 260 180, 220 200))");
247
		IFeature f1 = createTestFeature(pol1, index);
248
		index++;
249
		
250
		
251
		//Non error polygon
252
		Geometry pol2 = wktReader.read("POLYGON ((200 260, 440 80, 500 360, 380 380, 200 260))");
253
		IFeature f2 = createTestFeature(pol2, index);
254
		index++;
255
		
256
		//Polygon with selintersecting hole
257
		Geometry pol3 = wktReader.read("POLYGON ((100 80, 240 20, 460 200, 400 380, 220 400, 60 360, 0 220, 100 80), (100 320, 380 220, 60 180, 320 340, 100 320))");
258
		IFeature f3 = createTestFeature(pol3, index);
259
		index++;
260
		
261
		//unclosed polygon Por definicion JTS si comprueba que los linearRing sean cerrados en su construccion
262
//		Geometry pol4 = wktReader.read("POLYGON ((200 260, 440 80, 500 360, 380 380))");
263
		GeneralPathX gpx = new GeneralPathX();
264
		gpx.moveTo(200, 260);
265
		gpx.lineTo(440, 80);
266
		gpx.lineTo(500, 360);
267
		gpx.lineTo(380, 380);
268
		FPolygon2D polygon = new FPolygon2D(gpx);
269
		IGeometry pol4 = ShapeFactory.createGeometry(polygon);
270
		StringValue value = ValueFactory.createValue("s4");
271
		Value[] values = {value};
272
		DefaultFeature f4 = new DefaultFeature(pol4, values, "id4");
273

  
274
		index++;
275
		
276
		//it isnt a polygon. its a line (three collinear points: collapsed polygon)
277
//		Geometry pol5 = wktReader.read("POLYGON ((200 260, 440 80, 200 260))");
278
//		IFeature f5 = createTestFeature(pol5, index);
279
		GeneralPathX gpx2 = new GeneralPathX();
280
		gpx2.moveTo(200, 260);
281
		gpx2.lineTo(440, 80);
282
		gpx2.lineTo(200, 260);
283
		FPolygon2D polygon2 = new FPolygon2D(gpx2);
284
		IGeometry pol5 = ShapeFactory.createGeometry(polygon2);
285
		StringValue value2 = ValueFactory.createValue("s5");
286
		Value[] values2 = {value2};
287
		DefaultFeature f5 = new DefaultFeature(pol5, values2, "id5");
288
		index++;
289
		
290
		//Polygon with shell points in CCW order
291
		Geometry pol6 = wktReader.read("POLYGON ((100 320, 380 220, 60 180, 320 340, 100 320))");
292
		IFeature f6 = createTestFeature(pol6, index);
293
		index++;
294
		
295
		//Polygon with hole in CCW order
296
		Geometry pol7 = wktReader.read("POLYGON ((0 0, 1000 0, 1000 1000, 0 1000, 0 0), (100 80, 240 20, 460 200, 400 380, 220 400, 60 360, 0 220, 100 80))");
297
		IFeature f7 = createTestFeature(pol7, index);
298
		index++;
299
		
300
		//Polygon with two holes that touch in more than a point
301
		Geometry pol8 = wktReader.read("POLYGON ((40 380, 40 20, 500 20, 500 380, 40 380),"+
302
						"(140 320, 160 200, 240 160, 400 220, 300 340, 140 320),"+
303
						"(300 140, 420 300, 460 100, 300 140))");
304
		
305
		IFeature f8 = createTestFeature(pol8, index);
306
		index++;
307
		
308
		//the hole is ccw
309
		Geometry pol9 = wktReader.read("POLYGON ((160 320, 740 80, 740 340, 400 380, 160 320), (440 260, 600 200, 660 300, 500 300, 440 260))");
310
		IFeature f9 = createTestFeature(pol9, index);
311
		index++;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff