Revision 2402

View differences:

org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
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/maven-v4_0_0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.raster.wcs.app.wcsclient</artifactId>
6
	<packaging>jar</packaging>
7
	<name>Formats: WCS support</name>
8
	<description>Web Coverage Service support</description>
9
	
10
	<parent>
11
		<groupId>org.gvsig</groupId>
12
		<artifactId>org.gvsig.raster.wcs</artifactId>
13
		<version>2.2.0-SNAPSHOT</version>
14
	</parent>
15
	
16
	<dependencies>
17
		<dependency>
18
			<groupId>org.gvsig</groupId>
19
			<artifactId>org.gvsig.andami</artifactId>
20
			<scope>compile</scope>
21
		</dependency>
22
		<dependency>
23
			<groupId>org.gvsig</groupId>
24
			<artifactId>org.gvsig.raster.swing.api</artifactId>
25
			<scope>compile</scope>
26
		</dependency>
27
		<dependency>
28
			<groupId>org.gvsig</groupId>
29
			<artifactId>org.gvsig.raster.wcs.io</artifactId>
30
			<scope>compile</scope>
31
		</dependency>
32
		<dependency>
33
			<groupId>org.gvsig</groupId>
34
			<artifactId>org.gvsig.remoteclient</artifactId>
35
			<scope>compile</scope>
36
		</dependency>
37
		<dependency>
38
			<groupId>org.gvsig</groupId>
39
			<artifactId>org.gvsig.app.mainplugin</artifactId>
40
			<scope>compile</scope>
41
		</dependency>
42
		<dependency>
43
			<groupId>org.gvsig</groupId>
44
			<artifactId>org.gvsig.raster.lib.api</artifactId>
45
			<scope>compile</scope>
46
		</dependency>
47
		<dependency>
48
			<groupId>org.gvsig</groupId>
49
			<artifactId>org.gvsig.raster.fmap</artifactId>
50
			<scope>compile</scope>
51
		</dependency>
52
		<dependency>
53
			<groupId>org.gvsig</groupId>
54
			<artifactId>org.gvsig.fmap.control</artifactId>
55
			<scope>compile</scope>
56
		</dependency>
57
		<dependency>
58
			<groupId>org.gvsig</groupId>
59
			<artifactId>org.gvsig.utils</artifactId>
60
			<scope>compile</scope>
61
		</dependency>
62
		<dependency>
63
			<groupId>org.gvsig</groupId>
64
			<artifactId>org.gvsig.ui</artifactId>
65
			<scope>compile</scope>
66
		</dependency>
67
		<!--<dependency> <groupId>org.gvsig</groupId> <artifactId>org.gvsig.symbology.lib.api</artifactId> 
68
			<scope>compile</scope> </dependency> -->
69
		<dependency>
70
			<groupId>org.gvsig</groupId>
71
			<artifactId>org.gvsig.symbology.lib.impl</artifactId>
72
			<scope>compile</scope>
73
		</dependency>
74
		<dependency>
75
			<groupId>org.gvsig</groupId>
76
			<artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
77
			<scope>compile</scope>
78
		</dependency>
79
		<dependency>
80
			<groupId>org.gvsig</groupId>
81
			<artifactId>org.gvsig.raster.cache.lib.api</artifactId>
82
            <scope>compile</scope>
83
		</dependency>
84
		<dependency>
85
			<groupId>easymock</groupId>
86
			<artifactId>easymock</artifactId>
87
		</dependency>
88
		
89
		
90
		<dependency>
91
            <groupId>org.gvsig</groupId>
92
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
93
            <scope>compile</scope>
94
        </dependency>
95
        <dependency>
96
            <groupId>org.gvsig</groupId>
97
            <artifactId>org.gvsig.fmap.mapcontext.impl</artifactId>
98
            <scope>runtime</scope>
99
        </dependency>
100
        <dependency>
101
            <groupId>org.gvsig</groupId>
102
            <artifactId>org.gvsig.fmap.mapcontext.operation</artifactId>
103
            <scope>runtime</scope>
104
        </dependency>
105
		<dependency>
106
            <groupId>org.gvsig</groupId>
107
            <artifactId>org.gvsig.projection.api</artifactId>
108
            <scope>compile</scope>
109
        </dependency>
110
        <dependency>
111
            <groupId>org.gvsig</groupId>
112
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
113
            <scope>runtime</scope>
114
        </dependency>
115
         <dependency>
116
            <groupId>org.gvsig</groupId>
117
            <artifactId>org.gvsig.compat.api</artifactId>
118
            <scope>compile</scope>
119
        </dependency>
120
        <dependency>
121
            <groupId>org.gvsig</groupId>
122
            <artifactId>org.gvsig.compat.se</artifactId>
123
            <scope>compile</scope>
124
        </dependency>
125
        <dependency>
126
            <groupId>org.gvsig</groupId>
127
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
128
            <scope>compile</scope>
129
        </dependency>
130
        <dependency>
131
            <groupId>org.gvsig</groupId>
132
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
133
            <scope>compile</scope>
134
        </dependency>
135
        <dependency>
136
            <groupId>org.gvsig</groupId>
137
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
138
            <scope>compile</scope>
139
        </dependency>
140
        <dependency>
141
            <groupId>org.gvsig</groupId>
142
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
143
            <scope>compile</scope>
144
        </dependency>
145
        <dependency>
146
            <groupId>org.gvsig</groupId>
147
            <artifactId>org.gvsig.fmap.geometry.impl</artifactId>
148
            <scope>runtime</scope>
149
        </dependency>
150
        <dependency>
151
            <groupId>org.gvsig</groupId>
152
            <artifactId>org.gvsig.fmap.geometry.operation</artifactId>
153
            <scope>runtime</scope>
154
        </dependency>
155
	</dependencies>
156

  
157
	<properties>
158
		<gvsig.package.info.state>testing</gvsig.package.info.state>
159
		<gvsig.package.info.dependencies>required: org.gvsig.raster.tilecache.app -ge 2, required: org.gvsig.raster.mainplugin -ge 2</gvsig.package.info.dependencies>
160
		<gvsig.package.info.poolURL>http://devel.gvsig.org/download/projects/Raster/pool</gvsig.package.info.poolURL>
161
		<gvsig.package.info.categories>OGC,Remote Services,Raster</gvsig.package.info.categories>
162
		<gvsig.package.info.official>true</gvsig.package.info.official>
163
	</properties>
164
</project>
0 165

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Wed May 15 12:25:52 CEST 2013
3
buildNumber=48
0 4

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestFormatsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.FormatPanel;
24

  
25
public class TestFormatsPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private FormatPanel       desc     = null;
30

  
31
	public TestFormatsPanel() {
32
		desc = new FormatPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestFormatsPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestInfoPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.InfoPanel;
24

  
25
public class TestInfoPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private InfoPanel         desc     = null;
30

  
31
	public TestInfoPanel() {
32
		desc = new InfoPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestInfoPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestLayerPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.LayerPanel;
24

  
25
public class TestLayerPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private LayerPanel        desc     = null;
30

  
31
	public TestLayerPanel() {
32
		desc = new LayerPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestLayerPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestParameterPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.ParameterPanel;
24

  
25
public class TestParameterPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private ParameterPanel    desc     = null;
30

  
31
	public TestParameterPanel() {
32
		desc = new ParameterPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestParameterPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/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

  
26
  <dependencySets>
27
    <dependencySet>
28
      <useProjectArtifact>false</useProjectArtifact>
29
	  <useTransitiveDependencies>false</useTransitiveDependencies>
30
      <outputDirectory>lib</outputDirectory>
31
      <includes> 
32
				<include>org.gvsig:org.gvsig.raster.wcs.app.wcsclient:jar</include>
33
				<include>org.gvsig:org.gvsig.raster.wcs.io:jar</include>
34
	  </includes>
35
	</dependencySet>
36
  </dependencySets>
37
</assembly>
0 38

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

  
43
import java.awt.Dimension;
44
import java.awt.Graphics2D;
45
import java.awt.Point;
46
import java.awt.Rectangle;
47
import java.awt.geom.AffineTransform;
48
import java.awt.geom.NoninvertibleTransformException;
49
import java.awt.geom.Point2D;
50
import java.awt.geom.Rectangle2D;
51
import java.awt.image.BufferedImage;
52
import java.io.IOException;
53
import java.util.HashMap;
54
import java.util.List;
55

  
56
import javax.print.attribute.PrintRequestAttributeSet;
57

  
58
import org.cresques.cts.IProjection;
59
import org.gvsig.compat.net.ICancellable;
60
import org.gvsig.fmap.dal.DALLocator;
61
import org.gvsig.fmap.dal.DataManager;
62
import org.gvsig.fmap.dal.DataParameters;
63
import org.gvsig.fmap.dal.DataStore;
64
import org.gvsig.fmap.dal.DataStoreParameters;
65
import org.gvsig.fmap.dal.coverage.RasterLocator;
66
import org.gvsig.fmap.dal.coverage.RasterManager;
67
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
68
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData;
69
import org.gvsig.fmap.dal.coverage.exception.FilePaletteException;
70
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException;
71
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
72
import org.gvsig.fmap.dal.coverage.exception.QueryException;
73
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
74
import org.gvsig.fmap.dal.coverage.grid.RasterFilter;
75
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
76
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
77
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
78
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
79
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
80
import org.gvsig.fmap.dal.exception.DataException;
81
import org.gvsig.fmap.dal.exception.InitializeException;
82
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
83
import org.gvsig.fmap.dal.exception.ReadException;
84
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
85
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
86
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
87
import org.gvsig.fmap.geom.GeometryLocator;
88
import org.gvsig.fmap.geom.GeometryManager;
89
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
90
import org.gvsig.fmap.geom.primitive.Envelope;
91
import org.gvsig.fmap.mapcontext.ViewPort;
92
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
93
import org.gvsig.fmap.mapcontext.layers.FLayer;
94
import org.gvsig.fmap.mapcontext.layers.Tiling;
95
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster;
96
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
97
import org.gvsig.raster.fmap.layers.NotAvailableStateException;
98
import org.gvsig.raster.util.CancelTaskImpl;
99
import org.gvsig.raster.wcs.io.WCSDataParameters;
100
import org.gvsig.raster.wcs.io.WCSProvider;
101
import org.gvsig.raster.wcs.io.WCSServerExplorer;
102
import org.gvsig.raster.wcs.io.WCSServerExplorerParameters;
103
import org.gvsig.tools.ToolsLocator;
104
import org.gvsig.tools.dynobject.DynObjectSet;
105
import org.gvsig.tools.dynobject.DynStruct;
106
import org.gvsig.tools.persistence.PersistenceManager;
107
import org.gvsig.tools.task.Cancellable;
108
import org.gvsig.tools.task.SimpleTaskStatus;
109
import org.gvsig.tools.task.TaskStatusManager;
110
import org.slf4j.Logger;
111
import org.slf4j.LoggerFactory;
112

  
113

  
114
/**
115
 * Class for the WCS layer.
116
 *
117
 * Capa para el WCS.
118
 *
119
 * Las capas WCS son tileadas para descargarlas del servidor. Esto quiere decir que
120
 * est?n formadas por multiples ficheros raster. Por esto la fuente de datos raster (IRasterDatasource)
121
 * de la capa FLyrWCS es un objeto de tipo CompositeDataset. Este objeto est? compuesto por un array
122
 * bidimensional de MultiRasterDataset. Cada uno de los MultiRasterDataset corresponde con un tile
123
 * salvado en disco. Estos MultiRasterDataset se crean cada vez que se repinta ya que en WCS a cada
124
 * zoom varian los ficheros fuente. La secuencia de creaci?n de un CompositeDataset ser?a la siguiente:
125
 * <UL>
126
 * <LI>Se hace una petici?n de dibujado por parte del usuario llamando al m?todo draw de FLyrWCS</LI>
127
 * <LI>Se tilea la petici?n</LI>
128
 * <LI>Cada tile se dibuja abriendo una FLyrRaster para ese tile</LI>
129
 * <LI>Si es el primer dibujado se guarda una referencia en la capa WCS a las propiedades de renderizado, orden de bandas,
130
 * transparencia, filtros aplicados, ...</LI>
131
 * <LI>Si no es el primer dibujado se asignan las propiedades de renderizado cuya referencia se guarda en la capa WCS</LI>
132
 * <LI>Se guarda el MultiRasterDataset de cada tile</LI>
133
 * <LI>Al acabar todos los tiles creamos un CompositeDataset con los MultiRasterDataset de todos los tiles</LI>
134
 * <LI>Asignamos a la capa la referencia de las propiedades de renderizado que tenemos almacenadas. De esta forma si hay
135
 * alguna modificaci?n desde el cuadro de propiedades ser? efectiva sobre los tiles que se dibujan.</LI>
136
 * </UL>
137
 *
138
 * @author jaume - jaume.dominguez@iver.es
139
 */
140
@SuppressWarnings("deprecation")
141
public class FLyrWCS extends DefaultFLyrRaster {
142
    private static final int             MAX_RETRY_TIMES           = 5;
143

  
144
    private static final GeometryManager geomManager               = GeometryLocator.getGeometryManager();
145
    private static final Logger          logger                    = LoggerFactory.getLogger(FLyrWCS.class);
146
    private boolean 					 isPrinting                = false;
147

  
148
    private boolean 					 mustTileDraw              = false;
149
    private int 						 maxTileDrawWidth          = 1023;
150
    private int							 maxTileDrawHeight         = 1023;
151
    private final int 					 maxTilePrintWidth         = 1023;
152
    private final int 					 maxTilePrintHeight        = 1023;
153

  
154
    private boolean						 firstLoad                 = false;
155
    private Envelope					 fullEnvelope              = null;
156
    private int                          callCount;
157
    private RasterManager                rManager                  = RasterLocator.getManager();
158
    private WCSServerExplorer            explorer                  = null;
159
    private boolean                      deleteCache               = false;
160

  
161
    @SuppressWarnings("unused")
162
    private class MyCancellable implements ICancellable {
163
        private Cancellable original;
164

  
165
        public MyCancellable(Cancellable cancelOriginal) {
166
            this.original = cancelOriginal;
167
        }
168

  
169
        public boolean isCanceled() {
170
            return original.isCanceled();
171
        }
172

  
173
        public Object getID() {
174
            return this;
175
        }
176
    }
177

  
178
    public FLyrWCS() {
179
        super();
180
        this.updateDrawVersion();
181
        try {
182
            enableAwake();
183
        } catch (NotAvailableStateException e) {
184
            logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e);
185
        }
186
    }
187

  
188
    public FLyrWCS(DataStoreParameters dataStoreParameters) throws Exception {
189
        this();
190
        //Create the explorer and connect
191
        DataManager dataManager = DALLocator.getDataManager();
192
        WCSServerExplorerParameters explorerParams = (WCSServerExplorerParameters) 
193
        dataManager.createServerExplorerParameters(WCSProvider.NAME);
194
        explorerParams.setHost((String)dataStoreParameters.getDynValue("uri"));
195
        WCSServerExplorer wmsServerExplorer = 
196
            (WCSServerExplorer) dataManager.openServerExplorer(WCSProvider.NAME, explorerParams);
197
        wmsServerExplorer.connect(null);
198
        wmsServerExplorer.getCoverageList();
199
        
200
        //Set the parameters
201
        setParameters((WCSDataParameters)dataStoreParameters);
202
        setExplorer(wmsServerExplorer);
203
    }
204

  
205
    public static DataStore createDataStore(String host, IProjection srs) throws InitializeException {
206
        DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
207
        RasterDataParameters params = null;
208
        try {
209
            params = (RasterDataParameters)dataman.createServerExplorerParameters(WCSProvider.NAME);
210
        } catch (InitializeException e) {
211
            return null;
212
        } catch (ProviderNotRegisteredException e) {
213
            return null;
214
        }
215
        params.setURI(host);
216
        params.setSRS(srs);
217

  
218
        try {
219
            return dataman.openStore(params.getDataStoreName(), params);
220
        } catch (ValidateDataParametersException e) {
221
            throw new InitializeException(e);
222
        } catch (ProviderNotRegisteredException e) {
223
            throw new InitializeException(e);
224
        }
225
    }
226

  
227
    public void setDataStore(DataStore dataStore) throws LoadLayerException {
228
        this.dataStore = (RasterDataStore) dataStore;
229
        try {
230
            if(this.dataStore.isOpen())
231
                enableOpen();
232
        } catch (NotAvailableStateException e) {
233
            logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e);
234
        }
235
        setProjection(this.dataStore.getProjection());
236
    }
237

  
238
    public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws ReadException {
239
        TaskStatusManager manager = ToolsLocator.getTaskStatusManager();
240
		SimpleTaskStatus taskStatus = new RasterTaskStatus("Drawing " + getName() + "...", cancel);
241
		manager.add(taskStatus);
242
		taskStatus.setAutoremove(true);
243

  
244
        if(!firstLoad) {
245
            try {
246
                initFilters();
247
                try {
248
					if(!isOpen())
249
						enableOpen();
250
				} catch (NotAvailableStateException e) {
251
					throw new ReadException("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), e);
252
				}
253
            } catch (FilePaletteException e) {
254
                logger.error(e.getMessage(), this, e);
255
            }
256
            firstLoad = true;
257
        }
258

  
259
        callCount = 0;  
260

  
261
        enableStopped();
262
        
263
        if(recalcLevel) {
264
			double pixelSize = viewPort.getEnvelope().getLength(0) / (double)viewPort.getImageWidth();
265
			zoomLevel = dataStore.getNearestLevel(pixelSize);
266
		}
267
		recalcLevel = true;
268

  
269
        if (isWithinScale(scale)) {
270

  
271
            if(mustTileDraw) {
272
                Point2D p = viewPort.getOffset();
273
                Rectangle r = new Rectangle((int) p.getX(), (int) p.getY(), viewPort.getImageWidth(), viewPort.getImageHeight());
274
                Tiling tiles = new Tiling(maxTileDrawWidth, maxTileDrawHeight, r);
275
                tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
276

  
277
                for (int tileNr = 0; tileNr < tiles.getNumTiles(); tileNr++) {
278
                    // drawing part
279
                    try {
280
                        ViewPort vp = tiles.getTileViewPort(viewPort, tileNr);
281
                        drawTile(g, vp, taskStatus, scale);
282
                    } catch (LoadLayerException e) {
283
                        throw new ReadException(e.getMessage(), e);
284
                    } catch (NoninvertibleTransformException e) {
285
                        throw new ReadException(e.getMessage(), e);
286
                    }
287
                }
288
            } else {
289
                try {
290
                    drawTile(g, viewPort, taskStatus, scale);
291
                } catch (LoadLayerException e) {
292
                    throw new ReadException(e.getMessage(), e);
293
                }
294
            }
295
        }
296
        disableStopped();
297

  
298
        /*Runtime r = Runtime.getRuntime();
299
		System.err.println("********************WCS**********************");
300
		System.err.println("Memoria Total: " + (r.totalMemory() / 1024) +"KB");
301
		System.err.println("Memoria Usada: " + ((r.totalMemory() - r.freeMemory()) / 1024) +"KB");
302
		System.err.println("Memoria Libre: " + (r.freeMemory() / 1024) +"KB");
303
		System.err.println("Memoria MaxMemory: " + (r.maxMemory() / 1024) +"KB");
304
		System.err.println("*********************************************");*/
305
    }
306

  
307
    /**
308
     * This is the method used to draw a tile in a WCS mosaic layer.
309
     * @throws LoadLayerException
310
     * @throws ReadDriverException
311
     * @return true when a tile has been painted
312
     */
313
    private void drawTile(Graphics2D g, ViewPort vp, SimpleTaskStatus taskStatus, double scale) throws LoadLayerException, ReadException {
314
        callCount++;
315

  
316
        // Compute the query geometry
317
        // 1. Check if it is within borders
318
        Envelope envelope = getFullEnvelope();
319
        Envelope vpEnv = vp.getAdjustedExtent();
320
        if (!vpEnv.intersects(envelope)) {
321
            return;
322
        }
323

  
324
        // 2. Compute extent to be requested.
325
        Rectangle2D bBox = new Rectangle2D.Double();
326
        Rectangle2D.intersect(getRectable2DFromEnvelope(vpEnv),
327
            getRectable2DFromEnvelope(envelope), bBox);
328

  
329
        // 3. Compute size in pixels
330
        double scalex = vp.getAffineTransform().getScaleX();
331
        double scaley = vp.getAffineTransform().getScaleY();
332
        int wImg = (int) Math.ceil(Math.abs(bBox.getWidth() * scalex) + 1);
333
        int hImg = (int) Math.ceil(Math.abs(bBox.getHeight() * scaley) + 1);
334

  
335
        Dimension sz = new Dimension(wImg, hImg);
336

  
337
        if ((wImg <= 0) || (hImg <= 0)) {
338
            return;
339
        }
340

  
341
        try {
342
            //Rectangle2D extent = new Rectangle2D.Double();
343
            //Rectangle2D.Double vpExtent = this.getRectable2DFromEnvelope(vpEnv);
344
            //Rectangle2D.intersect(vpExtent, bBox, extent);
345

  
346
            Extent ex = rManager.getDataStructFactory().createExtent(
347
                vp.getAdjustedEnvelope().getMinimum(0), 
348
                vp.getAdjustedEnvelope().getMaximum(1), 
349
                vp.getAdjustedEnvelope().getMaximum(0), 
350
                vp.getAdjustedEnvelope().getMinimum(1));
351
            ViewPortData vpData = rManager.getDataStructFactory().createViewPortData(vp.getProjection(), ex, sz );
352
            vpData.setMat(vp.getAffineTransform());
353
    		
354
            try {
355
                getParameters().setExtent(bBox);
356
                getParameters().setWidth(wImg);
357
                getParameters().setHeight(hImg);
358
                if(getDataStore().getParameters() instanceof WCSDataParameters) {
359
					getRender().draw(g, vpData, taskStatus);
360
                } else {
361
                	Envelope adjustedExtent = vp.getAdjustedExtent();
362
					Extent e = rManager.getDataStructFactory().createExtent(adjustedExtent.getLowerCorner().getX(),
363
							adjustedExtent.getUpperCorner().getY(), adjustedExtent.getUpperCorner().getX(),
364
							adjustedExtent.getLowerCorner().getY());
365
					ViewPortData vp2 = rManager.getDataStructFactory().createViewPortData(vp.getProjection(), e, vp.getImageSize() );
366
					vp2.setMat(vp.getAffineTransform());
367
					getParameters().setExtent(ex.toRectangle2D());
368
					getRender().drawTiledService(g, vp2, vp.getImageSize(), taskStatus);
369
                }
370
            /*} catch (RasterDriverException e) {
371
            	setAvailable(false);
372
				JOptionPane.showMessageDialog(null, "Problems drawing this layer:" + e.getMessage(), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE);
373
				logger.info("Problems drawing this layer:" + e.getMessage(), e);*/
374
            } catch (ProcessInterruptedException e) {
375
            } catch (QueryException e) {
376
            	throw new RemoteServiceException("Problems drawing this layer: " + e.getMessage(), e);
377
			} finally {
378
            	taskStatus.terminate();            	
379
            }
380

  
381
        } catch (RemoteServiceException e) {
382
            if (!taskStatus.isCancellationRequested()) {
383
                if (callCount < MAX_RETRY_TIMES) {
384
                    logger.warn("\n[ FLyrWCS.drawFixedSize() ]  Failed in trying " + callCount + "/" + MAX_RETRY_TIMES + ")\n"); // mess code
385
                    drawTile(g, vp, taskStatus, scale);
386
                } else {
387
                    if (!isPrinting) {
388
                        this.setVisible(false);
389
                    }
390
                    throw new LoadLayerException(getName(), e);
391
                }
392
            }
393
        }
394
        callCount--;
395
        return;
396
    }
397

  
398
    /**
399
     * Gets the explorer
400
     * @return
401
     */
402
    public WCSServerExplorer getExplorer() {
403
        return this.explorer;
404
    }
405

  
406
    /**
407
     * <p>
408
     * Gets the max resolution allowed by the coverage. Requesting a higher resolution
409
     * than this value does not cause any error, but the info responsed is just an
410
     * interpolation. <br>
411
     * </p>
412
     *
413
     * <p>
414
     * In exchange for obtaining a greater file and without additional information,
415
     * we can easily fit it into the View. <br>
416
     * </p>
417
     *
418
     * <p>
419
     * Obtiene la resoluci?n m?xima soportada por la cobertura. La petici?n
420
     * de una resoluci?n superior a la soportada no provoca ning?n error, aunque
421
     * la informaci?n obtenida s?lo es una mera interpolaci?n de informaci?n. <br>
422
     * </p>
423
     *
424
     * <p>
425
     * A cambio de obtener un archivo mayor y sin informaci?n adicional, podemos
426
     * f?cilmente acoplarlo a la vista. <br>
427
     * </p>
428
     *
429
     * @return double
430
     */
431
    public Point2D getMaxResolution() {
432
        return explorer.getMaxResolution(getName());
433
    }
434

  
435
    private Rectangle2D.Double getRectable2DFromEnvelope(Envelope env) {
436
        return new Rectangle2D.Double(env.getMinimum(0), env.getMinimum(1), env
437
            .getLength(0), env.getLength(1));
438
    }
439

  
440
    /**
441
     * Calcula el contenido del fichero de georreferenciaci?n de una imagen.
442
     * @param bBox Tama?o y posici?n de la imagen (en coordenadas de usuario)
443
     * @param sz Tama?o de la imagen en pixeles.
444
     * @return el 'WorldFile', como String.
445
     * @throws IOException
446
     */
447
    public String getDataWorldFile(Rectangle2D bBox, Dimension sz) throws IOException {
448
        StringBuffer data = new StringBuffer();
449
        data.append((bBox.getMaxX() - bBox.getMinX()) / (sz.getWidth() - 1) + "\n");
450
        data.append("0.0\n");
451
        data.append("0.0\n");
452
        data.append("-" + (bBox.getMaxY() - bBox.getMinY()) / (sz.getHeight() - 1) + "\n");
453
        data.append("" + bBox.getMinX() + "\n");
454
        data.append("" + bBox.getMaxY() + "\n");
455
        return data.toString();
456
    }
457

  
458
    public FLayer cloneLayer() throws Exception {
459
        RasterDataStore  ds = dataStore.cloneDataStore();
460
        FLyrWCS layer = new FLyrWCS();
461
        layer.setName(getParameters().getCoverageName());
462
        layer.setOpenRasterStore(ds);
463
        layer.fullEnvelope = fullEnvelope;
464
        layer.explorer = explorer;
465

  
466
        List<RasterFilter> filters = getRender().getFilterList().getStatusCloned();
467

  
468
        //Hacemos una copia de las bandas a renderizar
469
        ColorInterpretation ci = getRender().getRenderColorInterpretation();
470
		if(ci != null) {
471
			layer.getRender().setRenderColorInterpretation(ci.cloneColorInterpretation());
472
		}
473

  
474
        //Asignamos el entorno
475
        if(layer.getRender().getFilterList() == null)
476
            layer.getRender().setFilterList(RasterLocator.getManager().createEmptyFilterList(getRender().getFilterList().getInitDataType()));
477
        layer.getRender().getFilterList().setEnv(getRender().getFilterList().getEnv());
478
        layer.getRender().getFilterList().setStatus(filters);
479

  
480
        // Asignamos los valores noData del original
481
        layer.setNoDataValue(getNoDataValue());
482
        if(dataStore.getNoDataValue().isDefined())
483
        	layer.setNoDataTransparent(true);
484
        layer.enableOpen();
485

  
486
        return layer;
487
    }
488

  
489
    public Transparency getRenderTransparency() {
490
        return getRender().getRenderingTransparency();
491
    }
492

  
493
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws ReadException {
494
        if (isVisible() && isWithinScale(scale)){
495
            draw(null, g, viewPort, cancel, scale);
496
        }
497
    }
498

  
499
    /**
500
     * Inserta la extensi?n total de la capa en la proyeccion original.
501
     *
502
     * @param fullExtent
503
     *            Rect?ngulo.
504
     */
505
    public void setFullEnvelope(Envelope envelope) {
506
        Envelope cur = this.getFullEnvelope();
507
        if (cur == envelope) {
508
            return;
509
        }
510
        if (cur != null && cur.equals(envelope)) {
511
            return;
512
        }
513

  
514
        this.fullEnvelope = envelope;
515
        this.updateDrawVersion();
516
    }
517

  
518
    /**
519
     * Sets the layer's full extent.
520
     *
521
     * Establece la extensi?n m?xima de la capa.
522
     *
523
     * @param rect
524
     */
525
    public void setFullExtent(Rectangle2D fullExtent) {
526
        this.setFullEnvelope(this.getEnvelopeFromRectable2D(fullExtent));
527
    }
528

  
529
    private Envelope getEnvelopeFromRectable2D(Rectangle2D rect) {
530
        try {
531
            return geomManager.createEnvelope(rect.getMinX(), rect.getMinY(),
532
                rect.getMaxX(), rect.getMaxY(),
533
                SUBTYPES.GEOM2D);
534
        } catch (CreateEnvelopeException e) {
535
            logger.error("Error creating the envelope", e);
536
        }
537
        return null;
538
    }
539

  
540

  
541
    public HashMap<String, Object> getProperties() {
542
        HashMap<String, Object> info = new HashMap<String, Object>();
543
        try {
544
            info.put("name", getName());
545
            info.put("selectedLayers", getParameters().getCoverageName());
546
            info.put("host", getParameters().getURI());
547
            info.put("crs", getParameters().getSRSCode());
548
            info.put("format", getParameters().getFormat());
549
            info.put("time", getParameters().getTime());
550
            return info;
551
        } catch (Exception e) {
552
            e.printStackTrace();
553
        }
554
        return null;
555
    }
556

  
557
    public int[] getTileSize() {
558
        int[] size = {maxTileDrawWidth, maxTileDrawHeight};
559
        return size;
560
    }
561

  
562
    public String getTocImageIcon() {
563
        return "ico-WCS-Layer";
564
    }
565

  
566
    public boolean isTiled() {
567
        return mustTileDraw;
568
    }
569
    
570
	public boolean isRemote() {
571
		return true;
572
	}
573

  
574
    @Override
575
    public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel,
576
        boolean fast) throws LoadLayerException, DataException {
577

  
578
        //try {
579
        ViewPort viewPort = getMapContext().getViewPort();
580

  
581
        Point tiledPoint = new Point((int) p.getX() % maxTilePrintWidth, (int) p.getY() % maxTilePrintHeight);
582
        Rectangle rect = new Rectangle(0, 0, viewPort.getImageWidth() - 1, viewPort.getImageHeight() - 1);
583
        Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, rect);
584
        tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
585
        int nCols = tiles.getNumCols();
586

  
587
        int col = (int) p.getX() / maxTilePrintWidth;
588
        int row = (int) p.getY() / maxTilePrintHeight;
589
        int tileIndex = (row * nCols) + col;
590

  
591
        ViewPort vp = null;
592
        try {
593
            vp = tiles.getTileViewPort(viewPort, tileIndex);
594
        } catch (NoninvertibleTransformException e1) {
595
            throw new LoadLayerException("", e1);
596
        }
597

  
598
        getParameters().setExtent(this.getRectable2DFromEnvelope(vp.getAdjustedExtent()));
599
        getParameters().setWidth(vp.getImageWidth());
600
        getParameters().setHeight(vp.getImageHeight());
601

  
602
        CancelTaskImpl cancellable = new CancelTaskImpl(cancel);
603
        getParameters().setCancellable(cancellable);
604

  
605
        String fInfo;
606
        try {
607
            fInfo = getDataStore().getInfoByPoint(tiledPoint.getX(), tiledPoint.getY(), cancellable);
608
        } catch (InfoByPointException e) {
609
            throw new LoadLayerException("Error in getInfoByPoint", e);
610
        }
611
        return new DynObjectSetWCSInfo(fInfo, DynObjectSetWCSInfo.TYPE_TEXT);
612
    }
613
    
614
	@Override
615
	public String getFileFormat() {
616
		return "WCS";
617
	}
618

  
619
    public boolean isActionEnabled(int action) {
620
        switch (action) {
621
        case IRasterLayerActions.ZOOM_PIXEL_RESOLUTION:
622
        case IRasterLayerActions.FLYRASTER_BAR_TOOLS:
623
        case IRasterLayerActions.BANDS_FILE_LIST:
624
        case IRasterLayerActions.GEOLOCATION:
625
        case IRasterLayerActions.PANSHARPENING:
626
        case IRasterLayerActions.SAVE_COLORINTERP:
627
            return false;
628
        case IRasterLayerActions.BANDS_RGB:
629
        case IRasterLayerActions.REMOTE_ACTIONS:
630
        case IRasterLayerActions.COLOR_TABLE:
631
            return true;
632
        }
633

  
634
        return super.isActionEnabled(action);
635
    }
636

  
637
    public boolean overviewsSupport() {
638
        return false;
639
    }
640

  
641
    public org.gvsig.fmap.dal.coverage.datastruct.Extent getFullRasterExtent() {
642
        Envelope env = getFullEnvelope();
643
        double minx = env.getMinimum(0);
644
        double miny = env.getMinimum(1);
645
        double maxx = env.getMaximum(0);
646
        double maxy = env.getMaximum(1);
647
        Point2D ul = new Point2D.Double(minx, maxy);
648
        Point2D ur = new Point2D.Double(maxx, maxy);
649
        Point2D ll = new Point2D.Double(minx, miny);
650
        Point2D lr = new Point2D.Double(maxx, miny);
651
        return rManager.getDataStructFactory().createExtent(ul, lr, ur, ll);
652
    }
653

  
654
    public WCSDataParameters getParameters() {
655
        /*if(params == null) {
656
            DataManager datamanager = DALLocator.getDataManager();
657
            WCSServerExplorerParameters explorerParams = null;
658
            try {
659
                explorerParams = (WCSServerExplorerParameters) datamanager.createServerExplorerParameters(WCSServerExplorer.NAME);
660
                explorerParams.setHost("");
661
                explorer = (WCSServerExplorer) datamanager.createServerExplorer(explorerParams);
662
                DataStoreParameters parameters = explorer.getStoreParameters();
663
                if(parameters instanceof WCSDataParameters) {
664
                    params = (WCSDataParameters) parameters;
665
                }
666
            } catch (InitializeException e) {
667
            } catch (ProviderNotRegisteredException e) {
668
            } catch (ValidateDataParametersException e) {
669
            }
670
        }*/
671
        return getWCSParameters(getDataStore().getParameters());
672
    }
673
    
674
    /**
675
     * Gets <code>WCSDataParameters</code>
676
     * @param parameters
677
     * @return
678
     */
679
    private WCSDataParameters getWCSParameters(DataStoreParameters parameters) {
680
    	WCSDataParameters params = null;
681
    	if(parameters instanceof WCSDataParameters) {
682
			params = (WCSDataParameters) parameters;
683
		}
684
		
685
		if(parameters instanceof TileDataParameters) {
686
			DataParameters p = ((TileDataParameters) parameters).getDataParameters();
687
			if(p instanceof WCSDataParameters) {
688
				params = (WCSDataParameters) p;
689
			}
690
		}
691
		return params;
692
    }
693

  
694
    /**
695
     * Sets the explorer
696
     * @param explorer
697
     */
698
    public void setExplorer(WCSServerExplorer explorer) {
699
        this.explorer = explorer;
700
    }
701
    
702
    /**
703
	 * Assigns the flag to delete this layer from the cache
704
	 * @param selected
705
	 */
706
	public void deleteCache(boolean deleteCache) {
707
		this.deleteCache = deleteCache;
708
	}
709

  
710
    /**
711
     * Sets the data store parameters
712
     * @param params
713
     * @throws InitializeException
714
     */
715
    public void setParameters(DataStoreParameters params) throws InitializeException {
716
        if(params instanceof TileDataParameters) {
717
			((TileDataParameters)params).deleteCache(deleteCache);
718
		}
719
        
720
        DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
721
        try {
722
            DataStore dStore = dataman.openStore(params.getDataStoreName(), params);
723
            this.setDataStore(dStore);
724

  
725
			if(params instanceof WCSDataParameters) {
726
				this.setName((String)((WCSDataParameters)params).getURI());
727
			}
728
			
729
			if(params instanceof TileDataParameters) {
730
				DataParameters p = ((TileDataParameters) params).getDataParameters();
731
				if(p instanceof WCSDataParameters) {
732
					this.setName((String)((WCSDataParameters) p).getURI());
733
				}
734
			}
735
        } catch (ValidateDataParametersException e) {
736
            throw new InitializeException(e);
737
        } catch (ProviderNotRegisteredException e) {
738
            throw new InitializeException(e);
739
        } catch (LoadLayerException e) {
740
            throw new InitializeException(e);
741
        }
742
    }
743
    
744
	/*@Override
745
	public void loadFromState(PersistentState state)
746
	throws PersistenceException {
747
		String host = state.getString("host");
748
		
749
		getParameters();
750
		((WCSServerExplorerParameters)explorer.getParameters()).setHost(host);
751
		
752
		if(!explorer.isHostReachable()) {
753
			loadDataStore = false;
754
			super.loadFromState(state);
755
			return;
756
		}
757
		
758
		try {
759
			explorer.connect(new CancelTaskImpl());
760
			explorer.getCoverageList();
761
		} catch (Exception e) {
762
			loadDataStore = false;
763
			super.loadFromState(state);
764
			return;
765
		}
766
		
767
		loadDataStore = true;
768

  
769
		super.loadFromState(state);
770
		params = getDataStore().getParameters();
771
		this.fullEnvelope = (Envelope) state.get("fullEnvelope");
772
		try {
773
			if(this.dataStore.isOpen())
774
				enableOpen();
775
		} catch (NotAvailableStateException e) {
776
			logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e);
777
		}
778
		//getParameters().setCoverageName((String)state.get("name"));
779
	}*/
780

  
781
    /*@Override
782
	public void saveToState(PersistentState state) throws PersistenceException {
783
		super.saveToState(state);
784
		state.set("fullEnvelope", this.fullEnvelope);
785
		state.set("host", getParameters().getURI());
786
		state.set("name", getName());
787
	}*/
788
    
789
	/*public static void registerPersistent() {
790
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
791
		DynStruct definition = manager.getDefinition(PERSISTENT_NAME);
792
		if( definition == null ) {
793
			if (manager.getDefinition(FLyrDefault.class) == null) {
794
				FLyrDefault.registerPersistent();
795
			}
796

  
797
			definition = manager.addDefinition(
798
					FLyrWCS.class,
799
					PERSISTENT_NAME,
800
					PERSISTENT_DESCRIPTION,
801
					null, 
802
					null
803
			);
804
			
805
			definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, "FLyrDefault");
806
		}
807

  
808
		DefaultFLyrRaster.registerPersistence(definition);
809
		definition.addDynFieldObject("fullEnvelope").setClassOfValue(Envelope.class).setMandatory(false);
810
		definition.addDynFieldString("host").setMandatory(false);
811
		definition.addDynFieldString("name").setMandatory(false);
812
	}*/
813
	
814
	public static void registerPersistent() {
815
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
816
		DynStruct definition = manager.getDefinition("FLyrWCS_Persistent");
817
		if( definition == null ) {
818
			if (manager.getDefinition(DefaultFLyrRaster.class) == null) {
819
				DefaultFLyrRaster.registerPersistent();
820
			}
821

  
822
			definition = manager.addDefinition(
823
					FLyrWCS.class,
824
					"FLyrWCS_Persistent",
825
					"FLyrWCS Persistent Definition",
826
					null, 
827
					null
828
			);
829
			
830
			definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, DefaultFLyrRaster.PERSISTENT_NAME);
831
		}
832

  
833
		DefaultFLyrRaster.registerPersistence(definition);
834
	}
835
}
0 836

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/layer/DynObjectIteratorWCSInfo.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
package org.gvsig.raster.wcs.app.wcsclient.layer;
23

  
24
import java.util.ArrayList;
25

  
26
import org.gvsig.fmap.dal.feature.Feature;
27
import org.gvsig.tools.dispose.DisposableIterator;
28
import org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.dynobject.DynObjectSet;
30

  
31
/**
32
 * {@link DynObject} implementation to facade a iterator of a WCSInfo
33
 * and allow to be used as a {@link DynObjectSet} iterator.
34
 * 
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 * @version $Id$
37
 * 
38
 */
39
public class DynObjectIteratorWCSInfo implements DisposableIterator {
40

  
41
    private ArrayList<Object> infoList = new ArrayList<Object>();
42
    private int               index    = -1;
43

  
44
    /**
45
     * Creates a new DynObjects iterator facade over a feature iterator.
46
     * Each WMTSInfo will be returned through a new or reused
47
     * {@link DynObjectWMTSInfo} which allows the {@link Feature} to be
48
     * used like a DynObject.
49
     * 
50
     * @param featureIterator
51
     *            to facade
52
     * @param featureFacade
53
     *            if not null this object will be reused as the facade for the
54
     *            Feature objects of the feature iterator
55
     */
56
    public DynObjectIteratorWCSInfo(Object info) {
57
        this.infoList.add(info);
58
        index = 0;
59
    }
60
    
61
    public void addObject(Object info) {
62
    	this.infoList.add(info);
63
    	if(index == -1)
64
    		index = 0;
65
    }
66

  
67
    public synchronized void dispose() {
68
    	this.infoList.clear();
69
    	index = -1;
70
    }
71

  
72
    public synchronized boolean hasNext() {
73
        return (infoList.size() == 0 || index >= infoList.size()) ? false : true;
74
    }
75

  
76
    public synchronized Object next() {
77
        Object o = infoList.get(index);
78
        index ++;
79
        return o;
80
    }
81

  
82
    public synchronized void remove() {
83
    	if(index < infoList.size() && index >= 0) {
84
    		index --;
85
    		infoList.remove(index);
86
    	}
87
    }
88
    
89
    public long getSize() {
90
        return infoList.size();
91
    }
92
}
0 93

  
org.gvsig.raster.wcs/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/layer/DynObjectSetWCSInfo.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
package org.gvsig.raster.wcs.app.wcsclient.layer;
23

  
24
import org.gvsig.fmap.dal.feature.FeatureSet;
25
import org.gvsig.tools.ToolsLocator;
26
import org.gvsig.tools.dispose.DisposableIterator;
27
import org.gvsig.tools.dynobject.DynClass;
28
import org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.dynobject.DynObjectManager;
30
import org.gvsig.tools.dynobject.DynObjectSet;
31
import org.gvsig.tools.exception.BaseException;
32
import org.gvsig.tools.observer.Observable;
33
import org.gvsig.tools.observer.Observer;
34
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
35
import org.gvsig.tools.visitor.Visitor;
36

  
37
/**
38
 * {@link DynObject} implementation to facade of a {@link FeatureSet} and allow
39
 * to be used as a {@link DynObjectSet}.
40
 * 
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 * @version $Id$
43
 */
44
public class DynObjectSetWCSInfo extends BaseWeakReferencingObservable
45
    implements DynObjectSet, Observer {
46
	public static final int             TYPE_TEXT = 0;
47
	public static final int             TYPE_HTML = 1;
48
	public static final int             TYPE_XML  = 2;
49
	private DynObjectIteratorWCSInfo   ite = null;
50
	
51
	public static void registerDynClass() {
52
		DynObjectManager manager = ToolsLocator.getDynObjectManager();
53
    	DynClass dynClass = manager.add("WCSInfoByPoint", "WCS InfoByPoint");
54
    	dynClass.setNamespace("InfoByPoint");
55
    	dynClass.addDynFieldString("info");
56
	}
57
	
58
    /**
59
     * Creates a new facade over a given info, with fast dynobject
60
     * iteration.
61
     */
62
    public DynObjectSetWCSInfo(String txt, int type) {
63
    	DynObjectManager manager = ToolsLocator.getDynObjectManager();
64
    	DynObject dynObject = manager.createDynObject("WCSInfoByPoint");
65
    	dynObject.setDynValue("info", txt);
66
    	ite = new DynObjectIteratorWCSInfo(dynObject);
67
    }
68

  
69
    public void dispose() {
70

  
71
    }
72

  
73
    public void accept(final Visitor visitor, long firstValueIndex) throws BaseException {
74
    	while(ite.hasNext()) {
75
    		visitor.visit(ite.next());
76
    	}
77
    }
78

  
79
    public void accept(final Visitor visitor) throws BaseException {
80
    	while(ite.hasNext()) {
81
    		visitor.visit(ite.next());
82
    	}
83
    }
84

  
85
    public long getSize() throws BaseException {
86
       return ite.getSize();
87
    }
88

  
89
    public DisposableIterator iterator(long index) throws BaseException {
90
        return iterator();
91
    }
92

  
93
    public DisposableIterator iterator() throws BaseException {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff