Revision 128

View differences:

org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
  <modelVersion>4.0.0</modelVersion>
6
  <artifactId>org.gvsig.dgn</artifactId>
7
  <packaging>pom</packaging>
8
  <name>${project.artifactId}</name>
9
  <version>2.0.32</version>
10
  <description>DGN support fort DAL and gvSIG</description>
11
  <parent>
12
      <groupId>org.gvsig</groupId>
13
      <artifactId>org.gvsig.desktop</artifactId>
14
      <version>2.0.97</version>
15
  </parent>
16
  <url>https://devel.gvsig.org/redmine/projects/gvsig-dgn</url>
17

  
18
  <scm>
19
      <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-dgn/org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32</connection>
20
      <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-dgn/org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32</developerConnection>
21
      <url>https://devel.gvsig.org/redmine/projects/gvsig-dgn/repository/show/org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32</url>
22
  </scm>
23
    <repositories>
24
      <repository>
25
        <id>gvsig-public-http-repository</id>
26
        <name>gvSIG maven public HTTP repository</name>
27
        <url>http://devel.gvsig.org/m2repo/j2se</url>
28
        <releases>
29
          <enabled>true</enabled>
30
          <updatePolicy>daily</updatePolicy>
31
          <checksumPolicy>warn</checksumPolicy>
32
        </releases>
33
        <snapshots>
34
          <enabled>true</enabled>
35
          <updatePolicy>daily</updatePolicy>
36
          <checksumPolicy>warn</checksumPolicy>
37
        </snapshots>
38
      </repository>
39
    </repositories>
40
      
41
	<build>
42
		<plugins>
43
			<plugin>
44
				<groupId>org.apache.maven.plugins</groupId>
45
				<artifactId>maven-release-plugin</artifactId>
46
				<configuration>
47
					<tagBase>https://devel.gvsig.org/svn/gvsig-dgn/org.gvsig.dgn/tags</tagBase>
48
				</configuration>
49
			</plugin>
50
		</plugins>
51
	</build>
52

  
53
  <dependencyManagement>
54
      <dependencies>
55
          <dependency>
56
            <groupId>org.gvsig</groupId>
57
            <artifactId>org.gvsig.dgn.provider</artifactId>
58
            <version>2.0.32</version>
59
          </dependency>
60
          <dependency>
61
            <groupId>org.gvsig</groupId>
62
            <artifactId>org.gvsig.dgn.provider.legend</artifactId>
63
            <version>2.0.32</version>
64
          </dependency>
65
          <dependency>
66
            <groupId>org.gvsig</groupId>
67
            <artifactId>org.gvsig.dgn.app.mainplugin</artifactId>
68
            <version>2.0.32</version>
69
          </dependency>
70
      </dependencies>
71
  </dependencyManagement>
72

  
73
  <dependencies>
74
        <dependency>
75
            <groupId>org.slf4j</groupId>
76
            <artifactId>slf4j-api</artifactId>
77
            <scope>compile</scope>
78
        </dependency>
79
  </dependencies>
80

  
81
  <modules>
82
    <module>org.gvsig.dgn.app</module>
83
    <module>org.gvsig.dgn.provider</module>
84
    <module>org.gvsig.dgn.provider.legend</module>
85
  </modules>
86

  
87

  
88
</project>
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.app/org.gvsig.dgn.app.mainplugin/buildNumber.properties
1
#Tue May 19 12:02:04 CEST 2015
2
buildNumber=2089
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.app/org.gvsig.dgn.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
  <libraries library-dir="lib/"/>
4
  <depends plugin-name="org.gvsig.app"/>
5
  <resourceBundle name="text"/>
6
  <extensions>
7
     <extension class-name="org.gvsig.andami.LibraryExtension" active="false"/>
8
  </extensions>    
9
</plugin-config>
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.app/org.gvsig.dgn.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
  <dependencySets>
26
    <dependencySet>
27
      <useProjectArtifact>false</useProjectArtifact>
28
      <useTransitiveDependencies>false</useTransitiveDependencies>
29
      <outputDirectory>lib</outputDirectory>
30
      <includes>
31
        <include>org.gvsig:org.gvsig.dgn.provider.legend</include>
32
        <include>org.gvsig:org.gvsig.dgn.provider</include>
33
      </includes>
34
    </dependencySet>
35
  </dependencySets>
36

  
37
</assembly>
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.app/org.gvsig.dgn.app.mainplugin/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <artifactId>org.gvsig.dgn.app.mainplugin</artifactId>
5
  <packaging>jar</packaging>
6
  <name>Formats: DGN file format support</name>
7
  <description>DGN file format support</description>
8
  <parent>
9
      <groupId>org.gvsig</groupId>
10
      <artifactId>org.gvsig.dgn.app</artifactId>
11
      <version>2.0.32</version>
12
  </parent>
13

  
14
  <dependencies>
15
    <dependency>
16
        <groupId>org.gvsig</groupId>
17
        <artifactId>org.gvsig.tools.lib</artifactId>
18
        <scope>compile</scope>
19
    </dependency>
20
    <dependency>
21
        <groupId>org.gvsig</groupId>
22
        <artifactId>org.gvsig.andami</artifactId>
23
        <scope>compile</scope>
24
    </dependency>
25
    <dependency>
26
        <groupId>org.gvsig</groupId>
27
        <artifactId>org.gvsig.dgn.provider</artifactId>
28
        <scope>compile</scope>
29
    </dependency>
30
    <dependency>
31
        <groupId>org.gvsig</groupId>
32
        <artifactId>org.gvsig.dgn.provider.legend</artifactId>
33
        <scope>compile</scope>
34
    </dependency>
35

  
36
  </dependencies>
37
  
38
    <properties>
39
        <!-- Package info property values -->
40
        <!-- Default values in org.gvsig.desktop -->
41
        <gvsig.package.info.state>testing</gvsig.package.info.state>
42
        <gvsig.package.info.official>true</gvsig.package.info.official>
43
        <gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.1.0-A</gvsig.package.info.dependencies>
44
        <gvsig.package.info.categories>Formats,Vector</gvsig.package.info.categories>
45
        <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-dgn/pool/</gvsig.package.info.poolURL>
46
    </properties>
47
  
48
</project>
0 49

  
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.app/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <artifactId>org.gvsig.dgn.app</artifactId>
5
  <packaging>pom</packaging>
6
  <name>${project.artifactId}</name>
7
  <parent>
8
      <groupId>org.gvsig</groupId>
9
      <artifactId>org.gvsig.dgn</artifactId>
10
      <version>2.0.32</version>
11
  </parent>
12

  
13
  <modules>
14
    <module>org.gvsig.dgn.app.mainplugin</module>
15
  </modules>
16

  
17

  
18
</project>
0 19

  
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNGetLabeling.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.store.dgn.legend;
29

  
30
import org.gvsig.fmap.dal.exception.OpenException;
31
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider;
32
import org.gvsig.fmap.dal.store.dgn.LegendBuilder;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DynClass;
35
import org.gvsig.tools.dynobject.DynMethod;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.dynobject.DynObjectManager;
38
import org.gvsig.tools.dynobject.exception.DynMethodException;
39
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException;
40

  
41
public class DGNGetLabeling implements DynMethod {
42
	private static int code = DynObjectManager.NULLCODE;
43

  
44
	static void register(DynClass DGNDynClass) {
45
		if (code != DynObjectManager.NULLCODE) {
46
			return;
47
		}
48
		code = ToolsLocator.getDynObjectManager().registerDynMethod(
49
			DGNDynClass, 
50
			new DGNGetLabeling()
51
		);
52

  
53
	}
54
	public int getCode() throws DynMethodNotSupportedException {
55
		return code;
56
	}
57

  
58
	public String getDescription() {
59
		return "DGN Labeling";
60
	}
61

  
62
	public String getName() {
63
		return LegendBuilder.DYNMETHOD_GETLABELING_NAME;
64
	}
65

  
66
	public Object invoke(Object self, DynObject context)
67
			throws DynMethodException {
68
		try {
69
			return ((DGNStoreProvider) self).getLabeling();
70
		} catch (OpenException e) {
71
			//FIXME
72
			throw new RuntimeException(e);
73
		}
74
	}
75

  
76
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNGetLegend.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.store.dgn.legend;
29

  
30
import org.gvsig.fmap.dal.exception.OpenException;
31
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider;
32
import org.gvsig.fmap.dal.store.dgn.LegendBuilder;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DynClass;
35
import org.gvsig.tools.dynobject.DynMethod;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.dynobject.DynObjectManager;
38
import org.gvsig.tools.dynobject.exception.DynMethodException;
39
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException;
40

  
41
public class DGNGetLegend implements DynMethod {
42
	private static int code = DynObjectManager.NULLCODE;
43

  
44
	static void register(DynClass DGNDynClass) {
45
		if (code != DynObjectManager.NULLCODE) {
46
			return;
47
		}
48
		code = ToolsLocator.getDynObjectManager().registerDynMethod(
49
			DGNDynClass, 
50
			new DGNGetLegend()
51
		);
52

  
53
	}
54
	public int getCode() throws DynMethodNotSupportedException {
55
		return code;
56
	}
57

  
58
	public String getDescription() {
59
		return "DGN Legend";
60
	}
61

  
62
	public String getName() {
63
		return LegendBuilder.DYNMETHOD_GETLEGEND_NAME;
64
	}
65

  
66
	public Object invoke(Object self, DynObject context)
67
			throws DynMethodException {
68
		try {
69
			return ((DGNStoreProvider) self).getLegend();
70
		} catch (OpenException e) {
71
			throw new RuntimeException(e);
72
		}
73
	}
74

  
75
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNLegendLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.dal.store.dgn.legend;
32

  
33
import org.gvsig.fmap.dal.DALLibrary;
34
import org.gvsig.fmap.dal.store.dgn.DGNLibrary;
35
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider;
36
import org.gvsig.metadata.MetadataLibrary;
37
import org.gvsig.metadata.MetadataLocator;
38
import org.gvsig.tools.dynobject.DynClass;
39
import org.gvsig.tools.library.AbstractLibrary;
40
import org.gvsig.tools.library.LibraryException;
41

  
42
/**
43
 * @author jmvivo
44
 *
45
 */
46
public class DGNLegendLibrary extends AbstractLibrary {
47

  
48
    @Override
49
    public void doRegistration() {
50
        registerAsServiceOf(DALLibrary.class);
51
        require(DGNLibrary.class);
52
        require(MetadataLibrary.class);
53
    }
54

  
55
	@Override
56
	protected void doInitialize() throws LibraryException {
57
	}
58

  
59
	@Override
60
	protected void doPostInitialize() throws LibraryException {
61
		DynClass metadataDefinition = (DynClass) MetadataLocator.getMetadataManager()
62
			.getDefinition(DGNStoreProvider.METADATA_DEFINITION_NAME);
63
		DGNGetLegendBuilder.register(metadataDefinition);
64
		DGNGetLegend.register(metadataDefinition);
65
		DGNGetLabeling.register(metadataDefinition);
66
	}
67
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNGetLegendBuilder.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.store.dgn.legend;
29

  
30
import org.gvsig.fmap.dal.store.dgn.LegendBuilder;
31
import org.gvsig.tools.ToolsLocator;
32
import org.gvsig.tools.dynobject.DynClass;
33
import org.gvsig.tools.dynobject.DynMethod;
34
import org.gvsig.tools.dynobject.DynObject;
35
import org.gvsig.tools.dynobject.DynObjectManager;
36
import org.gvsig.tools.dynobject.exception.DynMethodException;
37
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException;
38

  
39
public class DGNGetLegendBuilder implements DynMethod {
40
	private static int code = DynObjectManager.NULLCODE;
41

  
42
	static void register(DynClass DGNDynClass) {
43
		if (code != DynObjectManager.NULLCODE) {
44
			return;
45
		}
46
		code = ToolsLocator.getDynObjectManager().registerDynMethod(
47
			DGNDynClass, 
48
			new DGNGetLegendBuilder()
49
		);
50

  
51
	}
52
	
53
	public int getCode() throws DynMethodNotSupportedException {
54
		return code;
55
	}
56

  
57
	public String getDescription() {
58
		return "DGN LegendBuilder creator";
59
	}
60

  
61
	public String getName() {
62
		return LegendBuilder.DYNMETHOD_BUILDER_NAME;
63
	}
64

  
65
	public Object invoke(Object self, DynObject context)
66
			throws DynMethodException {
67
		return new DGNLegendBuilder();
68
	}
69

  
70
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider.legend/src/main/java/org/gvsig/fmap/dal/store/dgn/legend/DGNLegendBuilder.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.store.dgn.legend;
29

  
30
import java.awt.Color;
31

  
32
import org.gvsig.fmap.dal.DataTypes;
33
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
34
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
35
import org.gvsig.fmap.dal.store.dgn.DGNStoreProvider;
36
import org.gvsig.fmap.dal.store.dgn.LegendBuilder;
37
import org.gvsig.fmap.dal.store.dgn.lib.DGNReader;
38
import org.gvsig.fmap.geom.Geometry;
39
import org.gvsig.fmap.mapcontext.MapContextLocator;
40
import org.gvsig.fmap.mapcontext.MapContextManager;
41
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend;
42
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
43
import org.gvsig.symbology.SymbologyLocator;
44
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.IAttrInTableLabelingStrategy;
45
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
46
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
47
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
48

  
49
public class DGNLegendBuilder implements LegendBuilder {
50

  
51
	private MapContextManager mapContextManager = MapContextLocator
52
			.getMapContextManager();
53

  
54
	private IVectorialUniqueValueLegend defaultLegend = null;
55
	private IAttrInTableLabelingStrategy labelingStragegy = null;
56

  
57
	public void begin() {
58
		// Nothing to do
59
	}
60

  
61
	public void end() {
62
		// Nothing to do
63
	}
64

  
65
	public Object getLegend() {
66
		return defaultLegend;
67
	}
68

  
69
	public LegendBuilder initialize(FeatureStoreProvider store) {
70
		defaultLegend = (IVectorialUniqueValueLegend) mapContextManager.createLegend(
71
						IVectorialUniqueValueLegend.LEGEND_NAME);
72
		defaultLegend.setShapeType(Geometry.TYPES.GEOMETRY);
73
		defaultLegend
74
				.setClassifyingFieldNames(new String[] { DGNStoreProvider.NAME_FIELD_COLOR });
75
		defaultLegend.setClassifyingFieldTypes(new int[] { DataTypes.INT });
76

  
77
		ISymbol myDefaultSymbol =
78
				mapContextManager.getSymbolManager()
79
				.createSymbol(Geometry.TYPES.GEOMETRY); 
80

  
81
		defaultLegend.setDefaultSymbol(myDefaultSymbol);
82
		defaultLegend.useDefaultSymbol(true);
83

  
84
		labelingStragegy = SymbologyLocator.getSymbologyManager().createAttrInTableLabelingStrategy();
85
		labelingStragegy.setTextField(DGNStoreProvider.NAME_FIELD_TEXT);
86
		labelingStragegy
87
				.setRotationField(DGNStoreProvider.NAME_FIELD_ROTATIONTEXT);
88
		labelingStragegy.setHeightField(DGNStoreProvider.NAME_FIELD_HEIGHTTEXT);
89
		labelingStragegy.setUnit(1); // MapContext.NAMES[1] (meters)
90
		return this;
91
	}
92

  
93
	public void process(FeatureProvider feature, DGNReader dgnReader) {
94
		Integer clave = (Integer) feature.get("Color");
95
		if (clave == null) {
96
			return;
97
		}
98

  
99
		defaultLegend.useDefaultSymbol(false);
100
		if (defaultLegend.getSymbolByValue(clave) == null) {
101
			ISymbol theSymbol;
102
			Color color = dgnReader.DGNLookupColor(clave.intValue());
103
			theSymbol =
104
					mapContextManager.getSymbolManager().createSymbol(
105
					Geometry.TYPES.GEOMETRY, color); 
106

  
107
			theSymbol.setDescription(clave.toString());
108

  
109
			if (theSymbol instanceof IMarkerSymbol) {
110
				((IMarkerSymbol) theSymbol).setSize(1);
111
			}
112

  
113
			if (theSymbol instanceof ILineSymbol) {
114
				ILineSymbol lineSymbol = (ILineSymbol) theSymbol;
115
				lineSymbol.setLineWidth(1);
116
				lineSymbol.setLineColor(color);
117
			}
118

  
119
			if (theSymbol instanceof IFillSymbol) {
120
				IFillSymbol fillSymbol = (IFillSymbol) theSymbol;
121
				fillSymbol.getOutline().setLineColor(color);
122
				fillSymbol.getOutline().setLineWidth(1);
123
				fillSymbol.setFillColor(null);
124
			}
125
			if (theSymbol != null) {
126
				defaultLegend.addSymbol(clave, theSymbol);
127
			}
128
		}
129
	}
130

  
131
	public Object getLabeling() {
132
		return labelingStragegy;
133
	}
134

  
135

  
136
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider.legend/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <artifactId>org.gvsig.dgn.provider.legend</artifactId>
5
  <packaging>jar</packaging>
6
  <name>${project.artifactId}</name>
7
  <description>DAL provider for DGN files</description>
8
  <parent>
9
      <groupId>org.gvsig</groupId>
10
      <artifactId>org.gvsig.dgn</artifactId>
11
      <version>2.0.32</version>
12
  </parent>
13

  
14
  <dependencies>
15

  
16
    <dependency>
17
      <groupId>org.gvsig</groupId>
18
      <artifactId>org.gvsig.dgn.provider</artifactId>
19
      <scope>compile</scope>
20
    </dependency>
21

  
22
    <dependency>
23
      <groupId>commons-io</groupId>
24
      <artifactId>commons-io</artifactId>
25
      <scope>compile</scope>
26
    </dependency>
27

  
28
    <dependency>
29
        <groupId>org.gvsig</groupId>
30
        <artifactId>org.gvsig.tools.lib</artifactId>
31
        <scope>compile</scope>
32
    </dependency>
33
    <dependency>
34
        <groupId>org.gvsig</groupId>
35
        <artifactId>org.gvsig.projection.api</artifactId>
36
        <scope>compile</scope>
37
    </dependency>
38
    <dependency>
39
        <groupId>org.gvsig</groupId>
40
        <artifactId>org.gvsig.fmap.dal.api</artifactId>
41
        <scope>compile</scope>
42
    </dependency>
43
    <dependency>
44
        <groupId>org.gvsig</groupId>
45
        <artifactId>org.gvsig.fmap.dal.spi</artifactId>
46
        <scope>compile</scope>
47
    </dependency>
48
    <dependency>
49
        <groupId>org.gvsig</groupId>
50
        <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
51
        <scope>compile</scope>
52
    </dependency>
53
    <dependency>
54
        <groupId>org.gvsig</groupId>
55
        <artifactId>org.gvsig.fmap.geometry.api</artifactId>
56
        <scope>compile</scope>
57
    </dependency>
58
    <dependency>
59
        <groupId>org.gvsig</groupId>
60
        <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
61
        <scope>compile</scope>
62
    </dependency>
63

  
64
    <dependency>
65
        <groupId>org.gvsig</groupId>
66
        <artifactId>org.gvsig.symbology.lib.api</artifactId>
67
        <scope>compile</scope>
68
    </dependency>
69
    <dependency>
70
        <groupId>org.gvsig</groupId>
71
        <artifactId>org.gvsig.timesupport.lib.api</artifactId>
72
        <scope>compile</scope>
73
    </dependency>  
74
    <dependency>
75
      <groupId>org.gvsig</groupId>
76
      <artifactId>org.gvsig.utils</artifactId>
77
      <scope>compile</scope>
78
    </dependency>
79

  
80

  
81
    <!-- TESTS -->
82
    <dependency>
83
      <groupId>org.gvsig</groupId>
84
      <artifactId>org.gvsig.tools.lib</artifactId>
85
      <type>test-jar</type>
86
      <scope>test</scope>
87
    </dependency>
88
    <dependency>
89
      <groupId>org.gvsig</groupId>
90
      <artifactId>org.gvsig.compat.se</artifactId>
91
      <scope>test</scope>
92
    </dependency>
93
    <dependency>
94
      <groupId>org.gvsig</groupId>
95
      <artifactId>org.gvsig.fmap.dal.impl</artifactId>
96
      <scope>test</scope>
97
    </dependency>
98
    <dependency>
99
      <groupId>org.gvsig</groupId>
100
      <artifactId>org.gvsig.fmap.geometry.generalpath</artifactId>
101
      <scope>test</scope>
102
    </dependency>
103
    <dependency>
104
      <groupId>org.gvsig</groupId>
105
      <artifactId>org.gvsig.projection.cresques.impl</artifactId>
106
      <scope>test</scope>
107
    </dependency>
108
    <dependency>
109
      <groupId>org.gvsig</groupId>
110
      <artifactId>org.gvsig.timesupport.lib.impl</artifactId>
111
      <scope>test</scope>
112
    </dependency>   
113

  
114

  
115
  </dependencies>
116

  
117
</project>
0 118

  
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider/src/test/java/org/gvsig/fmap/dal/store/dgn/TestDGN.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.store.dgn;
29

  
30
import java.io.File;
31
import java.net.URL;
32
import org.gvsig.fmap.dal.DALLocator;
33
import org.gvsig.fmap.dal.DataManager;
34

  
35
import org.gvsig.fmap.dal.DataStoreParameters;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.feature.FeatureStore;
38
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
39

  
40
import static junit.framework.Assert.assertNotNull;
41

  
42
public class TestDGN extends AbstractLibraryAutoInitTestCase {
43

  
44
	private File file_prueba = null;
45
        private DataManager dataManager = null;
46

  
47
        @Override
48
        protected void doSetUp() throws Exception {
49
            URL res = TestDGN.class.getResource("data/prueba.dgn");
50
            this.file_prueba = new File(res.getFile());
51
            this.dataManager = DALLocator.getDataManager();
52
        }
53

  
54
        
55
	/*
56
	 * (non-Javadoc)
57
	 *
58
	 * @see
59
	 * org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters
60
	 * ()
61
	 */
62
	public DataStoreParameters getDefaultDataStoreParameters()
63
			throws DataException {
64
            
65
		DGNStoreParameters dgnParameters = null;
66

  
67
		dgnParameters = (DGNStoreParameters) dataManager
68
				.createStoreParameters(DGNStoreProvider.NAME);
69

  
70
		dgnParameters.setFile(file_prueba.getAbsolutePath());
71
		dgnParameters.setCRS("EPSG:23030");
72
		return dgnParameters;
73
	}
74

  
75
	/*
76
	 * (non-Javadoc)
77
	 *
78
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
79
	 */
80
	public boolean hasExplorer() {
81
		// TODO Auto-generated method stub
82
		return false;
83
	}
84

  
85
	public boolean usesResources() {
86
		return true;
87
	}
88

  
89

  
90
	public void testLegendAndLabeling() throws Exception {
91
		FeatureStore store = (FeatureStore) dataManager.openStore(
92
                        DGNStoreProvider.NAME,
93
                        getDefaultDataStoreParameters()
94
                );
95

  
96
		assertNotNull(store.invokeDynMethod("getLegend", null));
97
		assertNotNull(store.invokeDynMethod("getLabeling", null));
98
		store.dispose();
99
	}
100
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/DGNStoreParameters.java
1
package org.gvsig.fmap.dal.store.dgn;
2

  
3
import java.io.File;
4
import java.util.regex.Pattern;
5
import org.apache.commons.lang3.StringUtils;
6

  
7
import org.cresques.cts.IProjection;
8
import org.gvsig.fmap.dal.DataStoreParameters;
9
import org.gvsig.fmap.dal.FileHelper;
10
import org.gvsig.fmap.dal.feature.EditableFeatureType;
11
import org.gvsig.fmap.dal.feature.FeatureType;
12
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
13
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
14
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
15
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
16
import org.gvsig.fmap.geom.Geometry;
17
import org.gvsig.tools.dynobject.DelegatedDynObject;
18

  
19
public class DGNStoreParameters extends AbstractDataParameters implements
20
        DataStoreParameters, FilesystemStoreParameters,
21
        NewFeatureStoreParameters {
22

  
23
    public static final String PARAMETERS_DEFINITION_NAME = "DGN";
24

  
25
    private static final String FIELD_FILE = "file";
26
    private static final String FIELD_CRS = "CRS";
27
    private static final String FIELD_XMLFILE = "XMLFile";
28
    private static final String FIELD_LOAD_MODE = "LoadMode";
29
    private static final String FIELD_RELOAD = "Reload";
30
    private static final String FIELD_GEOMTYPE_FILTER = "geomtypeFilter";
31
    private static final String FIELD_LEVEL_FILTER = "levelFilter";
32
    private static final String FIELD_TEXT_FILTER = "textFilter";
33
    private static final String FIELD_COLOR_FILTER = "colorFilter";
34
    private static final String FIELD_STYLE_FILTER = "styleFilter";
35
    private static final String FIELD_WEIGHT_FILTER = "weightFilter";
36
    private static final String FIELD_TYPE_FILTER = "typeFilter";
37
    private static final String FIELD_STYPE_FILTER = "stypeFilter";
38
    private static final String FIELD_GROUP_FILTER = "groupFilter";
39
    private static final String FIELD_ID_FILTER = "idFilter";
40
    private static final String FIELD_CROP_FILTER = "cropFilter";
41
    private static final String FIELD_CROPOPERATION_FILTER = "cropOperationFilter";
42
    private static final String FIELD_SKYPCORRUPTGEOMETRIES_FILTER = "skipCorruptGeometries";
43
    private static final String FIELD_SORT_BY_GEOMETRY_TYPE = "sortByGeometryType";
44
    private static final String FIELD_LOGS_ERRORS = "logErrors";
45
    private static final String FIELD_IGNORE_Z = "ignoreZ";
46
    private static final String FIELD_GROUPBY = "groupby";
47
//    private static final String FIELD_APPLYCONVEXHULL = "applyConvexHull";
48
    private static final String FIELD_USE_Z_AS_ELEVATION = "useZAsElevation";
49
    private static final String FIELD_ELEVATION_FACTOR = "elevationFactor";
50
    private static final String FIELD_ROUND_ELEVATION = "roundElevation";
51

  
52
    public static final String FIELD_LINK_FILTER_INDEX = "LinkFilterIndex";
53
    public static final String FIELD_LINK_FILTER_TYPE = "LinkFilterType";
54
    public static final String FIELD_LINK_FILTER_ENTITY = "LinkFilterEntity";
55
    public static final String FIELD_LINK_FILTER_MS = "LinkFilterMS";
56
    public static final String FIELD_LINK_FILTER_DATA = "LinkFilterData";
57

  
58
    public static final String FIELD_GROUP_GEOMETRIES_OPERATION = "GroupGeometriesOperation";
59
    public static final String FIELD_FORZE2D = "force2D";
60
    
61
    
62
    private DelegatedDynObject parameters;
63

  
64
    public DGNStoreParameters() {
65
        this(PARAMETERS_DEFINITION_NAME);
66
    }
67

  
68
    protected DGNStoreParameters(String parametersDefinitionName) {
69
        this(parametersDefinitionName, DGNStoreProvider.NAME);
70
    }
71

  
72
    public DGNStoreParameters(String parametersDefinitionName, String name) {
73
        super();
74
        this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName);
75
        this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name);
76
    }
77

  
78
    public String getDataStoreName() {
79
        return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
80
    }
81

  
82
    public String getDescription() {
83
        return this.getDynClass().getDescription();
84
    }
85

  
86
    public void setCRS(IProjection srs) {
87
        setDynValue(FIELD_CRS, srs);
88
    }
89

  
90
    public void setCRS(String srs) {
91
        setDynValue(FIELD_CRS, srs);
92
    }
93

  
94
    public IProjection getCRS() {
95
        return (IProjection) getDynValue(FIELD_CRS);
96
    }
97

  
98
    public String getFileName() {
99
        return this.getFile().getPath();
100
    }
101

  
102
    public boolean isValid() {
103
        if (getCRS() == null) {
104
            return false;
105
        }
106
        if (getFile() == null) {
107
            return false;
108
        }
109
        return true;
110
    }
111

  
112
    public File getFile() {
113
        return (File) this.getDynValue(FIELD_FILE);
114
    }
115

  
116
    public File getXMLFile() {
117
        return (File) this.getDynValue(FIELD_XMLFILE);
118
    }
119

  
120
    public int getGeometryTypeFilter() {
121
        Integer x = (Integer) this.getDynValue(FIELD_GEOMTYPE_FILTER);
122
        if (x == null) {
123
            return Geometry.TYPES.GEOMETRY;
124
        }
125
        return x.intValue();
126
    }
127

  
128
    public int getLoadMode() {
129
        Integer x = (Integer) this.getDynValue(FIELD_LOAD_MODE);
130
        if (x == null) {
131
            return DGNStoreProvider.LOAD_MODE_PLAIN;
132
        }
133
        return x.intValue();
134
    }
135
    
136
    public int getGroupGeometriesOperation() {
137
        Integer x = (Integer) this.getDynValue(FIELD_GROUP_GEOMETRIES_OPERATION);
138
        if (x == null) {
139
            return DGNStoreProvider.GROUP_GEOMETRIES_NONE;
140
        }
141
        return x.intValue();
142
    }
143
    
144
    public double geElevationFactor() {
145
        Double x = (Double) this.getDynValue(FIELD_ELEVATION_FACTOR);
146
        if (x == null) {
147
            return 1;
148
        }
149
        return x.doubleValue();
150
    }
151
    
152
    public int getCropOperationFilter() {
153
        Integer x = (Integer) this.getDynValue(FIELD_CROPOPERATION_FILTER);
154
        if (x == null) {
155
            return DGNStoreProvider.CROP_OPERATION_NONE;
156
        }
157
        return x.intValue();
158
    }
159

  
160
    public Geometry getCropFilter() {
161
        Geometry x = (Geometry) this.getDynValue(FIELD_CROP_FILTER);
162
        return x;
163
    }
164

  
165
    public String getGroupBy() {
166
        return (String) this.getDynValue(FIELD_GROUPBY);
167
    }
168

  
169
    public String getLevelFilter() {
170
        return (String) this.getDynValue(FIELD_LEVEL_FILTER);
171
    }
172

  
173
    public String getGroupFilter() {
174
        return (String) this.getDynValue(FIELD_GROUP_FILTER);
175
    }
176

  
177
    public String getTextFilter() {
178
        return (String) this.getDynValue(FIELD_TEXT_FILTER);
179
    }
180

  
181
    public String getIDFilter() {
182
        return (String) this.getDynValue(FIELD_ID_FILTER);
183
    }
184

  
185
    public String getTypeFilter() {
186
        return (String) this.getDynValue(FIELD_TYPE_FILTER);
187
    }
188

  
189
    public String getSTypeFilter() {
190
        return (String) this.getDynValue(FIELD_STYPE_FILTER);
191
    }
192

  
193
    public String getColorFilter() {
194
        return (String) this.getDynValue(FIELD_COLOR_FILTER);
195
    }
196

  
197
    public String getStyleFilter() {
198
        return (String) this.getDynValue(FIELD_STYLE_FILTER);
199
    }
200

  
201
    public String getWeightFilter() {
202
        return (String) this.getDynValue(FIELD_WEIGHT_FILTER);
203
    }
204

  
205
    public boolean useReload() {
206
        Boolean x = (Boolean) this.getDynValue(FIELD_RELOAD);
207
        if (x == null) {
208
            return Boolean.FALSE;
209
        }
210
        return x.booleanValue();
211
    }
212

  
213
//    public boolean getApplyConvexHull() {
214
//        Boolean x = (Boolean) this.getDynValue(FIELD_APPLYCONVEXHULL);
215
//        if (x == null) {
216
//            return Boolean.FALSE;
217
//        }
218
//        return x.booleanValue();
219
//    }
220

  
221
    public boolean getApplyRoundToElevation() {
222
        Boolean x = (Boolean) this.getDynValue(FIELD_ROUND_ELEVATION);
223
        if (x == null) {
224
            return Boolean.FALSE;
225
        }
226
        return x.booleanValue();
227
    }
228

  
229
     public String getLinkFilterData() {
230
        return StringUtils.trimToNull((String) this.getDynValue(FIELD_LINK_FILTER_DATA));
231
    }
232

  
233
     public Pattern getLinkFilterDataAsPattern() {
234
        String s = getLinkFilterData();
235
        if( s == null ) {
236
            return null;
237
        }
238
        return Pattern.compile(s);
239
    }
240

  
241
    public Integer getLinkFilterIndex() {
242
        return (Integer) this.getDynValue(FIELD_LINK_FILTER_INDEX);
243
    }
244

  
245
    public Integer getLinkFilterType() {
246
        return (Integer) this.getDynValue(FIELD_LINK_FILTER_TYPE);
247
    }
248

  
249
    public Integer getLinkFilterEntity() {
250
        return (Integer) this.getDynValue(FIELD_LINK_FILTER_ENTITY);
251
    }
252

  
253
    public Integer getLinkFilterMS() {
254
        return (Integer) this.getDynValue(FIELD_LINK_FILTER_MS);
255
    }
256

  
257
    
258
    public boolean ignoreZs() {
259
        Boolean x = (Boolean) this.getDynValue(FIELD_IGNORE_Z);
260
        if (x == null) {
261
            return Boolean.FALSE;
262
        }
263
        return x.booleanValue();
264
    }
265

  
266
    public boolean logErrors() {
267
        Boolean x = (Boolean) this.getDynValue(FIELD_LOGS_ERRORS);
268
        if (x == null) {
269
            return Boolean.FALSE;
270
        }
271
        return x.booleanValue();
272
    }
273

  
274
    public boolean skipCorruptGeometries() {
275
        Boolean x = (Boolean) this.getDynValue(FIELD_SKYPCORRUPTGEOMETRIES_FILTER);
276
        if (x == null) {
277
            return Boolean.FALSE;
278
        }
279
        return x.booleanValue();
280
    }
281

  
282
    boolean useZAsElevation() {
283
        Boolean x = (Boolean) this.getDynValue(FIELD_USE_Z_AS_ELEVATION);
284
        if (x == null) {
285
            return Boolean.FALSE;
286
        }
287
        return x.booleanValue();
288
    }
289

  
290
    boolean force2D() {
291
        Boolean x = (Boolean) this.getDynValue(FIELD_FORZE2D);
292
        if (x == null) {
293
            return Boolean.FALSE;
294
        }
295
        return x.booleanValue();
296
    }
297

  
298
    public boolean sortByGeometryType() {
299
        Boolean x = (Boolean) this.getDynValue(FIELD_SORT_BY_GEOMETRY_TYPE);
300
        if (x == null) {
301
            return Boolean.TRUE;
302
        }
303
        return x.booleanValue();
304
    }
305

  
306
    public void setFile(File file) {
307
        this.setDynValue(FIELD_FILE, file);
308
    }
309

  
310
    public void setFile(String file) {
311
        this.setDynValue(FIELD_FILE, file);
312
    }
313

  
314
    public EditableFeatureType getDefaultFeatureType() {
315
        return null; //TODO ????
316
    }
317

  
318
    public void setDefaultFeatureType(FeatureType defaultFeatureType) {
319
        throw new UnsupportedOperationException();
320
    }
321

  
322
    protected DelegatedDynObject getDelegatedDynObject() {
323
        return parameters;
324
    }
325

  
326

  
327
}
org.gvsig.dgn/tags/org.gvsig.dgn-2.0.32/org.gvsig.dgn.provider/src/main/java/org/gvsig/fmap/dal/store/dgn/PostProcessFilterOperation.java
1
package org.gvsig.fmap.dal.store.dgn;
2

  
3
import java.util.regex.Pattern;
4
import org.apache.commons.lang3.StringUtils;
5
import org.gvsig.fmap.dal.feature.FeatureType;
6
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
7
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_CONTAINS;
8
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_COVEREDBY;
9
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_COVERS;
10
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_CROSSES;
11
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_DISJOINT;
12
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_INTERSECT;
13
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_NONE;
14
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_OVERLAPS;
15
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_TOUCHES;
16
import static org.gvsig.fmap.dal.store.dgn.DGNStoreProvider.CROP_OPERATION_WITHIN;
17
import org.gvsig.fmap.geom.Geometry;
18
import org.gvsig.fmap.geom.GeometryLocator;
19
import org.gvsig.fmap.geom.GeometryManager;
20
import org.gvsig.fmap.geom.primitive.Point;
21
import org.gvsig.fmap.geom.type.GeometryType;
22
import org.slf4j.Logger;
23
import org.slf4j.LoggerFactory;
24

  
25
public class PostProcessFilterOperation {
26

  
27
    private static final Logger logger = LoggerFactory.getLogger(PostProcessFilterOperation.class);
28
            
29
    private Pattern levelFilter = null;
30
    private Pattern colorFilter = null;
31
    private Pattern styleFilter = null;
32
    private Pattern weighFilter = null;
33
    private Pattern typeFilter = null;
34
    private Pattern stypeFilter = null;
35
    private Pattern idFilter = null;
36
    private Pattern groupFilter = null;
37
    private Pattern textFilter = null;
38
    private Point pointForCheckGeometries = null;
39
    private boolean hasfilter = false;
40
    private boolean skipCurruptGeometries = true;
41
    private int geometryTypeFilter = Geometry.TYPES.GEOMETRY;
42
    private int counter_exceptions = 0;
43
    private int cropOperationFilter;
44
    private Geometry cropFilter = null;
45
    private int ID_FIELD_LEVEL = -1;
46
    private int ID_FIELD_COLOR = -1;
47
    private int ID_FIELD_STYLE = -1;
48
    private int ID_FIELD_WEIGHT = -1;
49
    private int ID_FIELD_TYPE = -1;
50
    private int ID_FIELD_STYPE = -1;
51
    private int ID_FIELD_GROUP = -1;
52
    private int ID_FIELD_ID = -1;
53
    private int ID_FIELD_TEXT = -1;
54

  
55
    PostProcessFilterOperation(DGNStoreParameters parameters, FeatureType featureType) {
56
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
57

  
58
        geometryTypeFilter = parameters.getGeometryTypeFilter();
59
        skipCurruptGeometries = parameters.skipCorruptGeometries();
60
        if (!StringUtils.isBlank(parameters.getLevelFilter())) {
61
            this.levelFilter = Pattern.compile(parameters.getLevelFilter());
62
            this.ID_FIELD_LEVEL = featureType.getIndex(DGNStoreProvider.NAME_FIELD_LEVEL);
63
            this.hasfilter = true;
64
        }
65
        if (!StringUtils.isBlank(parameters.getColorFilter())) {
66
            colorFilter = Pattern.compile(parameters.getColorFilter());
67
            this.ID_FIELD_COLOR = featureType.getIndex(DGNStoreProvider.NAME_FIELD_COLOR);
68
            this.hasfilter = true;
69
        }
70
        if (!StringUtils.isBlank(parameters.getStyleFilter())) {
71
            styleFilter = Pattern.compile(parameters.getStyleFilter());
72
            this.ID_FIELD_STYLE = featureType.getIndex(DGNStoreProvider.NAME_FIELD_STYLE);
73
            this.hasfilter = true;
74
        }
75
        if (!StringUtils.isBlank(parameters.getTypeFilter())) {
76
            this.typeFilter = Pattern.compile(parameters.getTypeFilter());
77
            this.ID_FIELD_TYPE = featureType.getIndex(DGNStoreProvider.NAME_FIELD_TYPE);
78
            this.hasfilter = true;
79
        }
80
        if (!StringUtils.isBlank(parameters.getSTypeFilter())) {
81
            this.stypeFilter = Pattern.compile(parameters.getSTypeFilter());
82
            this.ID_FIELD_STYPE = featureType.getIndex(DGNStoreProvider.NAME_FIELD_STYPE);
83
            this.hasfilter = true;
84
        }
85
        if (!StringUtils.isBlank(parameters.getWeightFilter())) {
86
            weighFilter = Pattern.compile(parameters.getWeightFilter());
87
            this.ID_FIELD_WEIGHT = featureType.getIndex(DGNStoreProvider.NAME_FIELD_WEIGHT);
88
            this.hasfilter = true;
89
        }
90
        if (!StringUtils.isBlank(parameters.getGroupFilter())) {
91
            groupFilter = Pattern.compile(parameters.getGroupFilter());
92
            this.ID_FIELD_GROUP = featureType.getIndex(DGNStoreProvider.NAME_FIELD_GROUP);
93
            this.hasfilter = true;
94
        }
95
        if (!StringUtils.isBlank(parameters.getIDFilter())) {
96
            idFilter = Pattern.compile(parameters.getIDFilter());
97
            this.ID_FIELD_ID = featureType.getIndex(DGNStoreProvider.NAME_FIELD_ID);
98
            this.hasfilter = true;
99
        }
100
        if (!StringUtils.isBlank(parameters.getTextFilter())) {
101
            textFilter = Pattern.compile(parameters.getTextFilter());
102
            this.ID_FIELD_TEXT = featureType.getIndex(DGNStoreProvider.NAME_FIELD_TEXT);
103
            this.hasfilter = true;
104
        }
105
        if (this.geometryTypeFilter != Geometry.TYPES.GEOMETRY) {
106
            this.hasfilter = true;
107
        }
108
        this.cropFilter = parameters.getCropFilter();
109
        if (this.cropFilter != null) {
110
            this.hasfilter = true;
111
        }
112
        this.cropOperationFilter = parameters.getCropOperationFilter();
113
        if (this.cropOperationFilter == CROP_OPERATION_NONE) {
114
            this.cropFilter = null;
115
        }
116
        this.pointForCheckGeometries = null;
117
        if (skipCurruptGeometries) {
118
            try {
119
                int geomSubtype = featureType.getDefaultGeometryAttribute().getGeomType().getSubType();
120
                this.pointForCheckGeometries = geomManager.createPoint(1, 1, geomSubtype);
121
                if (geomSubtype == Geometry.SUBTYPES.GEOM3D) {
122
                    this.pointForCheckGeometries.setCoordinateAt(Geometry.DIMENSIONS.Z, 1);
123
                }
124
            } catch (Exception ex) {
125
                this.pointForCheckGeometries = null;
126
            }
127
        }
128
    }
129
    
130
    public boolean hasFilter() {
131
        return this.hasfilter;
132
    }
133

  
134
    private boolean match(Pattern exp, Object value) {
135
        if (value == null) {
136
            return false;
137
        }
138
        return exp.matcher(value.toString()).matches();
139
    }
140

  
141
    public boolean accept(FeatureProvider data) {
142

  
143
        if (!this.hasfilter) {
144
            return true;
145
        }
146

  
147
        Geometry geometry = data.getDefaultGeometry();
148
        if (this.pointForCheckGeometries != null) {
149
            if (geometry != null) {
150
                try {
151
                    this.pointForCheckGeometries.intersects(geometry);
152
                } catch (Exception ex) {
153
                    // Skip geometries with problems
154
                    data.setDefaultGeometry(null);
155
                    geometry = null;
156
                }
157
            }
158
        }
159

  
160
        try {
161
            if (levelFilter!=null && !match(levelFilter, data.get(ID_FIELD_LEVEL))) {
162
                return false;
163
            }
164
            if (colorFilter!=null && !match(colorFilter, data.get(ID_FIELD_COLOR))) {
165
                return false;
166
            }
167
            if (styleFilter!=null && !match(styleFilter, data.get(ID_FIELD_STYLE))) {
168
                return false;
169
            }
170
            if (weighFilter!=null && !match(weighFilter, data.get(ID_FIELD_WEIGHT))) {
171
                return false;
172
            }
173
            if (typeFilter!=null && !match(typeFilter, data.get(ID_FIELD_TYPE))) {
174
                return false;
175
            }
176
            if (stypeFilter!=null && !match(stypeFilter, data.get(ID_FIELD_STYPE))) {
177
                return false;
178
            }
179
            if (groupFilter!=null && !match(groupFilter, data.get(ID_FIELD_GROUP))) {
180
                return false;
181
            }
182
            if (idFilter!=null && !match(idFilter, data.get(ID_FIELD_ID))) {
183
                return false;
184
            }
185
            if (textFilter!=null && !match(textFilter, data.get(ID_FIELD_TEXT))) {
186
                return false;
187
            }
188

  
189
            if (geometry != null) {
190
                if (geometryTypeFilter != Geometry.TYPES.GEOMETRY) {
191
                    GeometryType geomtype = geometry.getGeometryType();
192
                    switch (geometryTypeFilter) {
193
                        case Geometry.TYPES.POINT:
194
                            if (!geomtype.isTypeOf(Geometry.TYPES.POINT)
195
                                    && !geomtype.isTypeOf(Geometry.TYPES.MULTIPOINT)) {
196
                                return false;
197
                            }
198
                            break;
199
                        case Geometry.TYPES.CURVE:
200
                            if (!geomtype.isTypeOf(Geometry.TYPES.CURVE)
201
                                    && !geomtype.isTypeOf(Geometry.TYPES.MULTICURVE)) {
202
                                return false;
203
                            }
204
                            break;
205
                        case Geometry.TYPES.SURFACE:
206
                            if (!geomtype.isTypeOf(Geometry.TYPES.SURFACE)
207
                                    && !geomtype.isTypeOf(Geometry.TYPES.MULTISURFACE)) {
208
                                return false;
209
                            }
210
                            break;
211
                        default:
212
                            break;
213
                    }
214
                }
215
                if (this.cropFilter != null) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff