Revision 36506

View differences:

tags/v_1_12_0_Build_1402/libTopology/build.xml
1
<project name="libTopology" default="dist" basedir=".">
2
    <description>
3
        Genera el jar con libTopology y sus dependencias
4
    </description>
5
  <!-- set global properties for this build -->
6
	<property name="src" location="src"/>
7
	<property name="src-test" location="src-test"/>
8
	<property name="lib" location="lib"/>
9
	<property name="build" location="bin"/>
10
	<property name="build-test" location="bin-test"/>
11
	<property name="dist"  location="dist"/>
12
	<property name="jarName" value="org.gvsig.topology-lib.jar"/>
13
	<!--This could change, so we could copy this jar in lib directory of extTopology
14
	project-->
15
	<property name="targetDir" location="../libFMap/lib"/>
16
	<property name="topology.home" value="${build}/org/gvsig/topology" />
17
	<property name="i18n" location="../libInternationalization"/>
18
	<property name="i18nLibs" location="${i18n}/lib"/>
19
	<property name="andami" value="../_fwAndami"/>
20
	<property name="extensionsDir" location="${andami}/gvSIG/extensiones"/>
21
	<import file="../binaries/ant/utilities.xml"/>
22

  
23

  
24
  <target name="init">
25
    <tstamp/>
26
	<echo>
27
		Compiling ${ant.project.name}...
28
	</echo>
29
  </target>
30

  
31

  
32
	 <target name="dist" depends="init, create-jar, move-to-andami"
33
	        description="generate the distribution" >
34
	  </target>
35

  
36
	<target name="batch-build"
37
				description="compile the sources, create the jar file"
38
				depends="compile,create-jar,move-to-andami">
39
	</target>
40

  
41
	<target name="compile" description="compile the source" >
42
		<!-- Compile the Java code from ${src} to ${build} -->
43
		<mkdir dir="${build}" />
44
		<loadEclipseClasspath project="${basedir}"/>
45
		<gvSIG-javac
46
			classpath="${eclipseClasspath}"
47
		/>
48
	    <copy todir="${topology.home}/i18n/resources/translations">
49
	            <fileset dir="config" includes="*" />
50
	    </copy>
51
	</target>
52

  
53
	<target name="create-jar" description="Crea el jar de la aplicacion">
54
		<mkdir dir="${dist}"/>
55
	    <jar jarfile="${dist}/${jarName}" basedir="${build}"/>
56
	    <jar jarfile="${dist}/${jarName}" basedir="." includes = "images/*" update="true" />
57
	</target>
58

  
59

  
60
	<target name="move-to-fmap" description="Move jars and required libraries to fmap">
61
	    <copy todir="${dist}">
62
	    	<fileset dir="./lib" includes="*.jar"/>
63
	    </copy>
64
	    <move todir="${targetDir}/">
65
	    	<fileset dir="${dist}" includes="**/**"/>
66
	    </move>
67
	</target>
68

  
69
	<target name="move-to-andami" description="Move jars and required libraries to andami plugin directory">
70
		    <copy todir="${dist}">
71
		    	<fileset dir="./lib" includes="*.jar"/>
72
		    </copy>
73

  
74

  
75
		    <move todir="${extensionsDir}/com.iver.cit.gvsig/lib/">
76
		    	<fileset dir="${dist}" includes="**/**"/>
77
		    </move>
78
		</target>
79

  
80

  
81

  
82

  
83

  
84
	<target name="clean"
85
			description="clean up" >
86
		<!-- Delete the ${build} and ${dist} directory trees -->
87
		<delete dir="${build}"/>
88
		<delete dir="${dist}"/>
89
	</target>
90

  
91
	<target name="run-tests" depends="batch-build">
92
		<!--
93
		<antcall target="generic-run-tests">
94
			<param name="TestSuite.Name" value="org.cresques.cts.AllTests"/>
95
		</antcall>
96
		-->
97
	</target>
98
</project>
99

  
0 100

  
tags/v_1_12_0_Build_1402/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/castor-0.9.5.3-xml.jar"/>
12
	<classpathentry kind="lib" path="/_fwAndami/lib/org.gvsig.exceptions.jar"/>
13
	<classpathentry kind="lib" path="/libFMap/lib/driver-manager-1.1.jar" sourcepath="/libDriverManager"/>
14
	<classpathentry kind="lib" path="lib/jump-api-1.2-alpha4.jar"/>
15
	<classpathentry kind="lib" path="lib/jump-workbench.jar"/>
16
	<classpathentry kind="lib" path="lib/jcommon-0.8.4.jar"/>
17
	<classpathentry kind="lib" path="lib/jfreechart-0.9.9.jar"/>
18
	<classpathentry kind="lib" path="lib/roadmatcher-1.4.jar"/>
19
	<classpathentry kind="lib" path="/libFMap/lib/units-0.01.jar"/>
20
	<classpathentry kind="lib" path="/libFMap/lib/geoapi-2.0.jar"/>
21
	<classpathentry combineaccessrules="false" kind="src" path="/appgvSIG"/>
22
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
23
	<classpathentry kind="lib" path="lib/jai_core.jar"/>
24
	<classpathentry kind="lib" path="/libFMap/lib/vecmath-1.3.jar"/>
25
	<classpathentry kind="lib" path="/libFMap/lib/jts-1.9.jar"/>
26
	<classpathentry kind="lib" path="/libFMap/lib/geoutils.jar"/>
27
	<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.14.jar"/>
28
	<classpathentry kind="output" path="bin"/>
29
</classpath>
0 30

  
tags/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/libTopology/uml-jude/org/gvsig/topology/ITopologyRule.java
1
package org.gvsig.topology;
2

  
3
public interface ITopologyRule {
4
 
5
}
6
 
0 7

  
tags/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/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/v_1_12_0_Build_1402/libTopology/src-test/org/gvsig/topology/FGeometryUtilTest.java
1
/*
2
 * Created on 10-abr-2006
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
package org.gvsig.topology;
50

  
51
import java.awt.geom.Point2D;
52
import java.util.List;
53

  
54
import org.gvsig.fmap.core.FGeometryUtil;
55
import org.gvsig.fmap.core.ShapePointExtractor;
56

  
57
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
58
import com.iver.cit.gvsig.fmap.core.IGeometry;
59
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
60

  
61
import junit.framework.TestCase;
62

  
63
public class FGeometryUtilTest extends TestCase {
64
	public void testInsertVertex(){
65
		GeneralPathX gpx = new GeneralPathX();
66
		gpx.moveTo(0d, 0d);
67
		gpx.lineTo(100d, 0d);
68
		gpx.lineTo(300d, 150d);
69
		
70
		IGeometry geometry = ShapeFactory.createPolyline2D(gpx);
71
		Point2D newVertex = new Point2D.Double(50d, 0.02d);
72
		IGeometry newGeometry = FGeometryUtil.insertVertex(geometry, newVertex, 0.1);
73
		List<Point2D[]> pointList = ShapePointExtractor.extractPoints(newGeometry);
74
		Point2D[] points = pointList.get(0);
75
		assertTrue(points.length == 4);
76
	}
77
}
tags/v_1_12_0_Build_1402/libTopology/src-test/org/gvsig/topology/LineStringSelfIntersectionTest.java
1
/*
2
 * Created on 26-ago-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: LineStringSelfIntersectionTest.java,v $
48
 * Revision 1.4  2007/09/14 17:35:30  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.3  2007/09/10 14:42:13  azabala
52
 * *** empty log message ***
53
 *
54
 * Revision 1.2  2007/09/06 16:32:02  azabala
55
 * *** empty log message ***
56
 *
57
 * Revision 1.1  2007/08/27 18:05:59  azabala
58
 * first version in cvs
59
 *
60
 *
61
 */
62
package org.gvsig.topology;
63

  
64
import java.util.HashMap;
65

  
66
import junit.framework.TestCase;
67

  
68
import org.gvsig.jts.GeometryCracker;
69
import org.gvsig.jts.GeometrySnapper;
70
import org.gvsig.jts.JtsUtil;
71
import org.gvsig.jts.LineStringSelfIntersectionChecker;
72
import org.gvsig.jts.RobustLengthIndexedLine;
73
import org.gvsig.jts.SnapLineStringSelfIntersectionChecker;
74

  
75
import com.vividsolutions.jts.geom.Coordinate;
76
import com.vividsolutions.jts.geom.Geometry;
77
import com.vividsolutions.jts.geom.GeometryFactory;
78
import com.vividsolutions.jts.geom.LineString;
79
import com.vividsolutions.jts.geom.Polygon;
80
import com.vividsolutions.jts.geom.PrecisionModel;
81
import com.vividsolutions.jts.io.ParseException;
82
import com.vividsolutions.jts.io.WKTReader;
83

  
84
/**
85
 * To see visually the geometries used for testing, use JTS Test editor and
86
 * paste WKT code.
87
 * 
88
 * TODO Maybe edition in gvSIG would have a wkt editor, or a tool to select a
89
 * geometry and see it in WKT.
90
 * 
91
 * TODO To avoid robustness problems, is strongly encourage to create 
92
 * JTS geometries in gvSIG with a FIXED precision model (limit the number of significant decimals used in computations).
93
 * 
94
 * For example:
95
 * <ol>
96
 *  <li>new PrecisioModel(10000) consideer 4 decimals.</li>
97
 *  <li>new PrecisionModel(10) consideer 1 decimal.</li>
98
 * </ol>             
99
 * 
100
 * 
101
 * 
102
 */
103

  
104
public class LineStringSelfIntersectionTest extends TestCase {
105

  
106
	PrecisionModel pm = new PrecisionModel(10000);
107
	GeometryFactory factory = new GeometryFactory(pm);
108
	WKTReader wktReader = new WKTReader(factory);
109
	
110
	
111
	
112
	public void testRobustLenghtIndexedLine() throws ParseException{
113
		String wkt = "LINEARRING (-13900 -920, -8300 120, -5020 3460, -9480 5660, -15320 2620, -19420 4960, -19300 7600, -14620 8500, -13180 6840, -16380 5460, -22020 6280, -22340 3060, -18860 2120, -14820 4880, -10200 4460, -8680 2640, -8240 1780, -4420 -420, -5140 -2560, -9480 -3640, -12940 -2740, -13900 -920)";
114
		LineString lineString = (LineString) wktReader.read(wkt);
115
		LineStringSelfIntersectionChecker checker = new LineStringSelfIntersectionChecker(
116
				lineString, 0.01d);
117
		
118
		RobustLengthIndexedLine indexedLine = new RobustLengthIndexedLine(lineString);
119
		HashMap coordsIndex = new HashMap();
120
		// Con esta casuistica cubrimos el Outer Ring
121
		if (checker.hasSelfIntersections()) {
122
			Coordinate[] selfIntersection = checker.getSelfIntersections();
123
			for(int i = 0; i < selfIntersection.length; i++){
124
				Coordinate coord = selfIntersection[i];
125
				Double index = (Double) coordsIndex.get(coord);
126
				double indexD = 0d;
127
				if(index != null)
128
					indexD = index.doubleValue();
129
				double computedIndex = indexedLine.indexOfAfter(coord, indexD);
130
				computedIndex = indexedLine.indexOf(coord);
131
				coordsIndex.put(coord, new Double(computedIndex));
132
				System.out.println(coord.toString()+" - index = " + computedIndex);
133
			}	
134
		}
135
		//if in this point JTS doesnt launch an exception, RobustLenghtIndexedLine
136
		//solves all LenghtIndexedLine robustness problems
137
		assertTrue(true);
138
	}
139

  
140
	public void testCleanLineWith1SelfIntersection() throws ParseException {
141
		// linestring with one self intersection
142
		String wkt1 = "LINESTRING (-12378 3231, -14205 1381, -8845 2486, -11080 4794, -13820 -663)";
143

  
144
		LineString lineString = (LineString) wktReader.read(wkt1);
145

  
146
		LineStringSelfIntersectionChecker checker = new LineStringSelfIntersectionChecker(
147
				lineString);
148

  
149
		assertTrue(checker.hasSelfIntersections());
150

  
151
		Coordinate[] selfIntersections = checker.getSelfIntersections();
152

  
153
		assertTrue(selfIntersections.length == 1);
154

  
155
		Geometry[] cleanedLineString = checker.clean();
156

  
157
		assertTrue(cleanedLineString.length == 3);
158

  
159
	}
160

  
161
	public void testCleanLineWithManySelfIntersection() throws ParseException {
162
		String wkt2 = "LINESTRING (-16152 2534, -15190 5251, -10239 3808, -8316 -807, -11417 -1360, -11344 2246, -6128 5203, -600 2606, -1417 515, -3484 -1023, -5263 2486, -816 6765, 602 5948)";
163
		LineString lineString = (LineString) wktReader.read(wkt2);
164
		LineStringSelfIntersectionChecker checker = new LineStringSelfIntersectionChecker(
165
				lineString);
166
		checker.hasSelfIntersections();
167
		Coordinate[] selfIntersections = checker.getSelfIntersections();
168
		Geometry[] cleanedLineString = checker.clean();
169
		assertTrue(selfIntersections.length == 2);
170
		assertTrue(cleanedLineString.length == 5);
171
	}
172

  
173
	public void testPolygonSelfIntersected() throws ParseException {
174
		String wkt = "POLYGON ((-7571 299, -4686 5443, -13075 6452, -1441 1525, -7571 299))";
175
		Polygon polygon = (Polygon) wktReader.read(wkt);
176

  
177
		LineStringSelfIntersectionChecker checker = new LineStringSelfIntersectionChecker(
178
				polygon.getExteriorRing(), 0.01d);
179

  
180
		// Con esta casuistica cubrimos el Outer Ring
181
		if (checker.hasSelfIntersections()) {
182
			Coordinate[] selfIntersection = checker.getSelfIntersections();
183
			LineString[] splitted = (LineString[]) checker.clean();
184
			assertTrue(selfIntersection.length > 0);
185
			assertTrue(splitted.length == 2);
186
			assertTrue(JtsUtil.isClosed(splitted[0], 0.01d));
187
			//la solucion contiene un LinearRing (generado por polygonizer) y un 
188
			//LineString que ya estaba cerrado pero que por definicion nunca podr? ser closed
189
			assertTrue(JtsUtil.isClosed(splitted[1], 0.01d));
190
		}
191

  
192
		// Ahora habr?a que hacer lo mismo para cada anillo interior, y luego
193
		// asignarselos
194
		// a algun anillo exterior. Adem?s, habr?a que verificar reglas que
195
		// deben cumplir
196
		// los holes de un poligono
197

  
198
	}
199

  
200
	public void testPolygonWithManySelfIntersections() throws ParseException {
201
		String wkt = "LINESTRING (-13900 -920, -8300 120, -5020 3460, -9480 5660, -15320 2620, -19420 4960, -19300 7600, -14620 8500, -13180 6840, -16380 5460, -22020 6280, -22340 3060, -18860 2120, -14820 4880, -10200 4460, -8680 2640, -8240 1780, -4420 -420, -5140 -2560, -9480 -3640, -12940 -2740, -13900 -920)";
202
		LineString lineString = (LineString) wktReader.read(wkt);
203
		LineStringSelfIntersectionChecker checker = new LineStringSelfIntersectionChecker(
204
				lineString, 0.01d);
205

  
206
		// Con esta casuistica cubrimos el Outer Ring
207
		if (checker.hasSelfIntersections()) {
208
			Coordinate[] selfIntersection = checker.getSelfIntersections();
209
			LineString[] splitted = (LineString[]) checker.clean();
210
			assertTrue(selfIntersection.length == 4);
211
			assertTrue(splitted.length == 5);
212

  
213
			assertTrue(splitted[0].isClosed());
214
			assertTrue(splitted[1].isClosed());
215
			assertTrue(splitted[2].isClosed());
216
			assertTrue(splitted[3].isClosed());
217
			assertTrue(splitted[4].isClosed());
218
		}
219
	}
220
	
221
	
222
	public void testLineStringWithSelfIntersectionIfSnap() throws ParseException{
223
//		 linestring with one self intersection
224
		String wkt1 = "LINESTRING (-12378 3231, -14205 1381, -8845 2486, -11080 4794, -13820 -663)";
225
		LineString selfIntersectedLS = (LineString) wktReader.read(wkt1);
226
		SnapLineStringSelfIntersectionChecker checker = new SnapLineStringSelfIntersectionChecker(selfIntersectedLS, 0.01d);
227
		if(checker.hasSelfIntersections()){
228
			Coordinate[] selfIntersection = checker.getSelfIntersections();
229
			System.out.println(selfIntersection.length);
230
		}
231
		
232
		
233
		String wkt = "LINESTRING (100 100, 300 100, 300 300, 250 300, 250 100.01)";
234
		LineString lineString = (LineString) wktReader.read(wkt);
235
		checker = new SnapLineStringSelfIntersectionChecker(lineString, 0.1d);
236
		if(checker.hasSelfIntersections()){
237
			Coordinate[] selfIntersection = checker.getSelfIntersections();
238
			System.out.println(selfIntersection.length);
239
		}
240
	}
241
	
242
	public void testLineStringWithOneSnapSelfIntersection() throws ParseException{
243
		//a) use SnapSelfIntersectionChecker
244
		String wkt1 = "LINESTRING (100 100, 300 100, 300 300, 250 300, 250 100.01)";
245
		LineString lin = (LineString) wktReader.read(wkt1);
246
		SnapLineStringSelfIntersectionChecker checker = new SnapLineStringSelfIntersectionChecker(lin, 0.02);
247
		if(checker.hasSelfIntersections()){
248
			Coordinate[] selfIntersection = checker.getSelfIntersections();
249
			assertTrue(selfIntersection.length == 1);
250
			assertTrue(selfIntersection[0].equals2D(new Coordinate(250, 100)));
251
		}
252
		
253
		
254
		
255
		//b) use previous crack and snap, and normal checker
256
		GeometryCracker cracker = new GeometryCracker(0.02);
257
		GeometrySnapper snapper = new GeometrySnapper(0.02);
258
		//peque?o truco para snapear y cracker una misma linea
259
		Geometry[] geoms = {lin, lin};
260
		geoms = cracker.crackGeometries(geoms);
261
		geoms = snapper.snap(geoms);
262
		
263
		LineStringSelfIntersectionChecker checker2 = new LineStringSelfIntersectionChecker((LineString) geoms[0]);
264
		if(checker2.hasSelfIntersections()){
265
			Coordinate[] intersections = checker2.getSelfIntersections();
266
			System.out.println(intersections.length);
267
		}
268
		//No funciona. Las lineas a cracker deben ser diferentes
269
		
270
		
271
	}
272
	
273
	
274
	public void testErrorFound1() throws ParseException{
275
		String wkt = "LINESTRING (232180.23144462315 4174489.509113544, 232121.61266760822 4174405.7675090614, 232124.40506564634 4174416.9332327805, 232123.90644495402 4174416.9085969683, 232115.9631261746 4174404.4976449297, 232067.30475050298 4174399.6315630404, 232052.7077264457 4174385.0335209747, 232034.86549405233 4174393.1435895893, 232015.40238810578 4174389.899602864, 231984.58502321702 4174375.302375205, 231944.03671616025 4174362.3262247005, 231905.10928265666 4174339.6191320284, 231871.0479310423 4174321.777917644, 231827.25563725995 4174290.9605527553, 231786.70610859265 4174256.8992011407, 231752.6457749871 4174221.2159579643, 231725.0726004257 4174192.021706248, 231707.2303680323 4174157.9603546336, 231692.633343975 4174122.2769078556, 231682.9011801965 4174083.3506959626, 231661.81597908627 4174050.9112359104, 231621.2676720295 4174023.338061349, 231592.07240230442 4174015.227992734, 231585.58422525148 4174003.874955402, 231566.12111930494 4174011.9840060086, 231533.68186285428 4174011.9840060086, 231514.21855330598 4174008.740019283, 231494.75442935067 4174007.1179241193, 231489.8883474614 4174015.227992734, 231467.18125478926 4174023.338061349, 231437.98598506418 4174034.6913022823, 231407.1696381842 4174055.7773177996, 231364.998217955 4174075.240627348, 231324.44991089823 4174096.325828458, 231293.6325460095 4174110.924074126, 231270.92545333735 4174138.4972486873, 231243.3520751742 4174170.9354871293, 231222.2658560552 4174204.9968387433, 231202.80275010865 4174240.6802855213, 231186.5836308877 4174277.984402251, 231183.33964416213 4174308.8017671397, 231186.5836308877 4174347.7289970415, 231198.15289328076 4174385.0078671537, 231189.2880729687 4174444.8474402777, 231208.8269187672 4174553.7110578213, 231209.96260934373 4174511.713513489, 231214.1568054491 4174506.680681764, 231214.1568054491 4174488.8384493706, 231217.4007921747 4174466.1313566985, 231219.02309094014 4174443.424060425, 231223.88795121887 4174412.606695536, 231231.99801983373 4174376.9244703683, 231231.99801983373 4174342.8631187542, 231230.37592467008 4174303.9356852504, 231240.1080884486 4174279.6064974144, 231262.81518112074 4174245.546163809, 231274.67213279032 4174232.371297994, 231300.94307054154 4174215.951631047, 231340.02279815616 4174185.246857927, 231390.26743508296 4174148.9595283507, 231406.12210716662 4174149.593340607, 231420.14477067956 4174141.740217404, 231460.69409574507 4174133.631166798, 231489.8883474614 4174144.98420413, 231525.57179423943 4174169.3135955674, 231553.14496880083 4174190.3996110843, 231583.96233368956 4174203.37474358, 231592.07240230442 4174214.729002522, 231598.6167734411 4174231.3412767276, 231624.74518996544 4174246.6582365823, 231656.5117462252 4174272.8992448756, 231712.09644992155 4174300.6916985246, 231739.66962448295 4174325.0219043694, 231763.99901592053 4174349.351295807, 231793.19428564562 4174360.704129537, 231809.41442287533 4174375.302375205, 231815.71711873155 4174387.576099662, 231848.0570175269 4174405.7675090614, 231898.3018580555 4174444.8474402777, 231926.21606555264 4174481.1349734557, 231962.50339512914 4174509.049180953, 232001.58352994727 4174520.213683062, 232037.87085952374 4174536.9633884504, 232085.32513442996 4174550.91947419, 232121.61266760822 4174581.6252653184, 232160.6925988246 4174617.912594895, 232199.7715120322 4174656.992526111, 232207.1351766217 4174659.294651129, 232228.72510647684 4174652.385629253, 232228.66158272998 4174652.31090741, 232213.72881938252 4174634.662300283, 232211.2239070192 4174632.1575915217, 232208.41522084086 4174620.2177739386, 232198.68305706233 4174599.131351218, 232182.46393784136 4174571.5581766567, 232161.10428156852 4174546.639154543, 232160.6925988246 4174545.3365105297, 232180.23144462315 4174489.509113544, 232180.23144462315 4174489.509113544)";
276
		LineString lin = (LineString) wktReader.read(wkt);
277
		SnapLineStringSelfIntersectionChecker checker = new SnapLineStringSelfIntersectionChecker(lin, 0.02);
278
		if(checker.hasSelfIntersections()){
279
			Coordinate[] selfIntersection = checker.getSelfIntersections();
280
			assertTrue(selfIntersection.length == 1);
281
			assertTrue(selfIntersection[0].equals2D(new Coordinate(250, 100)));
282
		}
283
		//Con 0.02 no da errores. Subimos a 0.1 la tolerancia de SNAP....
284
		checker = new SnapLineStringSelfIntersectionChecker(lin, 0.1);
285
		if(checker.hasSelfIntersections()){
286
			Coordinate[] selfIntersection = checker.getSelfIntersections();
287
			assertTrue(selfIntersection.length == 1);
288
			assertTrue(selfIntersection[0].equals2D(new Coordinate(250, 100)));
289
		}
290
	}
291
	
292
}
0 293

  
tags/v_1_12_0_Build_1402/libTopology/src-test/org/gvsig/topology/JtsSnapTest.java
1
/*
2
 * Created on 25/08/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: JtsSnapTest.java,v $
48
 * Revision 1.3  2007/09/14 17:35:30  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.2  2007/09/06 16:32:02  azabala
52
 * *** empty log message ***
53
 *
54
 * Revision 1.1  2007/08/27 18:05:59  azabala
55
 * first version in cvs
56
 *
57
 *
58
 */
59
package org.gvsig.topology;
60

  
61
import junit.framework.TestCase;
62

  
63
import org.gvsig.jts.GeometryCracker;
64
import org.gvsig.jts.GeometrySnapper;
65

  
66
import com.vividsolutions.jts.geom.Geometry;
67
import com.vividsolutions.jts.geom.GeometryCollection;
68
import com.vividsolutions.jts.geom.GeometryFactory;
69
import com.vividsolutions.jts.geom.LineString;
70
import com.vividsolutions.jts.geom.Point;
71
import com.vividsolutions.jts.geom.PrecisionModel;
72
import com.vividsolutions.jts.io.ParseException;
73
import com.vividsolutions.jts.io.WKTReader;
74
import com.vividsolutions.jts.operation.overlay.OverlayOp;
75
import com.vividsolutions.jts.operation.overlay.SnappingOverlayOperation;
76
import com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp;
77
import com.vividsolutions.jts.operation.overlay.snap.SnapOverlayOp;
78

  
79
// import com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp;
80
// import com.vividsolutions.jts.operation.overlay.snap.SnapOverlayOp;
81

  
82
/**
83
 * 
84
 * In these tests we are trying to probe the use of snapping and precision
85
 * reduction in JTS operations, to avoid undesired effects (for example spureus
86
 * lines in dissolve) and to allow clustering tolerance in topologies.
87
 * 
88
 * @author azabala
89
 * 
90
 */
91

  
92
/*
93
 * ?Ojo! Tenemos dos alternativas para aplicar Snap con JTS que son excluyentes.
94
 * 
95
 * a) Usar  clase SnapOverlayOperation de JTS 1.8. En este caso no se maneja el
96
 * concepto de tolerancia de snap, sino de "rejilla". El tama?o del snap vendr?
97
 * dada por la resoluci?n del PrecisionModel empleado (simplemente hay que usar
98
 * un PrecisionModel de tipo FIXED)
99
 * 
100
 * b) Usar las clases que hemos desarrollado en gvSIG dentro de
101
 * libFMap. En este caso si que se usa la tolerancia de snap. Estas clases han
102
 * sido testadas y funciona perfectamente para INTERSECCION entre lineas y
103
 * lineas.
104
 * 
105
 * Hay que testar resto de operaciones (UNION, DIFERENCIA, etc.) 
106
 * 
107
 */
108
public class JtsSnapTest extends TestCase {
109

  
110
	static String wktLS1 = "LINESTRING (260 120, 300 180, 420 180, 480 120)";
111

  
112
	static String wktLS2 = "LINESTRING (479.999 120, 459 114, 437 128, 426 130, 458 141)";
113

  
114
	// ESTA HABIENDO PROBLEMAS DE COMPILACION CON LA LIBRERIA JTS 1.8
115

  
116
	public void testLine0() throws ParseException {
117

  
118
		String wktLS1 = "LINESTRING (260 120, 300 180, 420 180, 480 120)";
119
		String wktLS2 = "LINESTRING (479.999 120, 459 114, 437 128, 426 130, 458 141)";
120
		GeometryFactory factory = new GeometryFactory(new PrecisionModel(1000));
121
		WKTReader wktReader = new WKTReader(factory);
122
		Geometry ls1 = wktReader.read(wktLS1);
123
		Geometry ls2 = wktReader.read(wktLS2);
124
		Geometry intersection = SnapOverlayOp.intersection(ls1, ls2);
125
		System.out.println(intersection.toText());
126
	}
127

  
128
	public void testLineLineJTS18DEFAULT() throws ParseException {
129
		GeometryFactory factory = new GeometryFactory();
130
		WKTReader wktReader = new WKTReader(factory);
131
		Geometry ls1 = wktReader.read(wktLS1);
132
		Geometry ls2 = wktReader.read(wktLS2);
133

  
134
		Geometry intersection = SnapIfNeededOverlayOp.intersection(ls1, ls2);
135
		System.out.println(intersection.toText());
136
		assertTrue(intersection instanceof GeometryCollection);
137
		GeometryCollection sol = (GeometryCollection) intersection;
138
		assertTrue(sol.getNumGeometries() == 0);
139

  
140
	}
141

  
142
	// SnapIfNeeded solo actua si se producen errores de precision en el calculo
143
	// de overlays
144
	// si no hay ningun error, pasa del snap
145
	public void testLineLineJTS18PMFIXED() throws ParseException {
146
		GeometryFactory factory = new GeometryFactory(new PrecisionModel(1));
147
		WKTReader wktReader = new WKTReader(factory);
148
		Geometry ls1 = wktReader.read(wktLS1);
149
		Geometry ls2 = wktReader.read(wktLS2);
150
		Geometry intersection = SnapOverlayOp.intersection(ls1, ls2);
151
		System.out.println(intersection.toText());
152
		// assertTrue(!(intersection instanceof GeometryCollection));
153
		GeometryCollection sol = (GeometryCollection) intersection;
154
		assertTrue(sol.getNumGeometries() != 0);
155
	}
156

  
157
	public void testLineLineJTS18PMFIXED2() throws ParseException {
158
		GeometryFactory factory = new GeometryFactory(new PrecisionModel(1000));
159
		WKTReader wktReader = new WKTReader(factory);
160
		Geometry ls1 = wktReader.read(wktLS1);
161
		Geometry ls2 = wktReader.read(wktLS2);
162
		Geometry intersection = SnapOverlayOp.intersection(ls1, ls2);
163
		System.out.println(intersection.toText());
164
		assertTrue(!(intersection instanceof GeometryCollection));
165
	}
166

  
167
	/*
168
	 * El resultado de estos tres primeros tests es el siguiente:
169
	 * GEOMETRYCOLLECTION EMPTY MULTIPOINT (458 141, 480 120) LINESTRING
170
	 * (479.999 120, 480 120)
171
	 * 
172
	 * El snap de JTS viene determinado por el PrecisionModel
173
	 * 
174
	 * En el primer caso, el PrecisionModel es el por defecto (maxima
175
	 * precisi?n), luego no se intersectan.
176
	 * 
177
	 * En el segundo caso, el PrecisionModel tiene una resoluci?n de 0.1, luego
178
	 * considera que el primer y ultimo punto de la segunda linea intersectan.
179
	 * AHORA BIEN. Como no hay desplazamiento, considera que (480, 120) y
180
	 * (479.999, 120) son el mismo punto. Deber?an desplazarse??
181
	 * 
182
	 * 
183
	 * 
184
	 * En el tercer caso ya da resultados no deseados. Los puntos (479.999 120)
185
	 * y (480, 120) si aplicamos una tolerancia de snap grande deben ser
186
	 * considerados el mismo punto, pero si la tolerancia de snap es peque?a
187
	 * (1000 = 0.001 de resolucion) no deber?a dar un LineString de solucion
188
	 * REPORTAR A JTS-LIST
189
	 */
190

  
191
	// TEST DE PRUEBA CON LAS CLASES DE JTS 1.7
192
	// OJO!!!!!!
193
	// EL SNAP DE GVSIG SOLO FUNCIONA CON JTS 1.7. CON JTS 1.8 NO COMPILA
194
	/**
195
	 * 
196
	 * Intersects two lines with the GvSig snap overlay api
197
	 * (com.vividsolutions.jts.overlay.SnappingOverlayOperation) with many snap
198
	 * tolerances.
199
	 * 
200
	 * The PrecisionModel of the geometries doesnt change.
201
	 * 
202
	 */
203
	public void testIntersectionLineLineGvSIG() throws ParseException {
204
		GeometryFactory factory = new GeometryFactory();
205
		WKTReader wktReader = new WKTReader(factory);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff