Revision 9002
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/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.mosaic.provider</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<description></description> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.mosaic</artifactId> |
|
13 |
<version>3.0.0-SNAPSHOT</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.mosaic.lib.impl</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
|
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
|
|
34 |
|
|
35 |
<!-- TESTS --> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
39 |
<type>jar</type> |
|
40 |
<version>3.0.152</version> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>junit</groupId> |
|
44 |
<artifactId>junit</artifactId> |
|
45 |
<version>3.8.1</version> |
|
46 |
<type>jar</type> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
51 |
<version>3.0.0-SNAPSHOT</version> |
|
52 |
<type>jar</type> |
|
53 |
</dependency> |
|
54 |
</dependencies> |
|
55 |
<build> |
|
56 |
<plugins> |
|
57 |
<!-- |
|
58 |
<plugin> |
|
59 |
<groupId>org.codehaus.mojo</groupId> |
|
60 |
<artifactId>animal-sniffer-maven-plugin</artifactId> |
|
61 |
<executions> |
|
62 |
<execution> |
|
63 |
<id>check-java-api</id> |
|
64 |
<phase>package</phase> |
|
65 |
<goals> |
|
66 |
<goal>check</goal> |
|
67 |
</goals> |
|
68 |
<configuration> |
|
69 |
<skip>true</skip> |
|
70 |
<signature> |
|
71 |
<groupId>org.codehaus.mojo.signature</groupId> |
|
72 |
<artifactId>java18</artifactId> |
|
73 |
<version>1.0</version> |
|
74 |
</signature> |
|
75 |
</configuration> |
|
76 |
</execution> |
|
77 |
</executions> |
|
78 |
</plugin> |
|
79 |
--> |
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
</plugins> |
|
84 |
</build> |
|
85 |
|
|
86 |
</project> |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.mosaic.MosaicStoreLibrary |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/resources/org/gvsig/mosaic/MosaicStoreMetadata.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of metadata fields of a JIMI file. |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
|
|
9 |
<class name="MosaicStore" namespace="Metadata"> |
|
10 |
<extends> |
|
11 |
<class namespace="Metadata" name="SpatialProvider"/> |
|
12 |
</extends> |
|
13 |
<description>Metadata of a Mosaic store</description> |
|
14 |
<fields> |
|
15 |
</fields> |
|
16 |
</class> |
|
17 |
|
|
18 |
</classes> |
|
19 |
</definitions> |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/resources/org/gvsig/mosaic/MosaicStoreParameters.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class name="MosaicStoreProviderParameters"> |
|
6 |
<extends> |
|
7 |
<class namespace="dal" name="ProviderParameters"/> |
|
8 |
</extends> |
|
9 |
<description>Store the parameters need to open a mosaic file</description> |
|
10 |
<fields> |
|
11 |
<field name="mosaicFile" type="File"> |
|
12 |
<description></description> |
|
13 |
</field> |
|
14 |
</fields> |
|
15 |
</class> |
|
16 |
</classes> |
|
17 |
</definitions> |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/java/org/gvsig/mosaic/MosaicStoreLibrary.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.mosaic; |
|
7 |
|
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.List; |
|
10 |
import java.util.logging.Level; |
|
11 |
import java.util.logging.Logger; |
|
12 |
import org.gvsig.fmap.dal.DALFileLibrary; |
|
13 |
import org.gvsig.fmap.dal.DALLibrary; |
|
14 |
import org.gvsig.fmap.dal.FileHelper; |
|
15 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
|
16 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
17 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
18 |
import org.gvsig.tools.library.AbstractLibrary; |
|
19 |
import org.gvsig.tools.library.LibraryException; |
|
20 |
|
|
21 |
/** |
|
22 |
* |
|
23 |
* @author osc |
|
24 |
*/ |
|
25 |
public class MosaicStoreLibrary extends AbstractLibrary { |
|
26 |
|
|
27 |
@Override |
|
28 |
public void doRegistration() { |
|
29 |
registerAsServiceOf(DALLibrary.class); |
|
30 |
require(DALFileLibrary.class); |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
protected void doInitialize() throws LibraryException { |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void doPostInitialize() throws LibraryException { |
|
39 |
List<Throwable> exs = new ArrayList<Throwable>(); |
|
40 |
|
|
41 |
// String filename = "MosaicStoreParameters.xml"; |
|
42 |
FileHelper.registerParametersDefinition( |
|
43 |
MosaicStoreProviderParameters.PARAMETERS_DEFINITION_NAME, |
|
44 |
MosaicStoreProviderParameters.class, |
|
45 |
MosaicStoreProvider.NAME+"Parameters.xml"); |
|
46 |
try { |
|
47 |
FileHelper.registerMetadataDefinition( |
|
48 |
MosaicStoreProvider.METADATA_DEFINITION_NAME, |
|
49 |
MosaicStoreProvider.class, |
|
50 |
MosaicStoreProvider.NAME+"Metadata.xml"); |
|
51 |
} catch (MetadataException ex) { |
|
52 |
throw new RuntimeException("Not able to register metadata definition",ex); |
|
53 |
} |
|
54 |
// List<Throwable> exs = new ArrayList<Throwable>(); |
|
55 |
// |
|
56 |
// FileHelper.registerParametersDefinition( |
|
57 |
// PngStoreProviderParameters.PARAMETERS_DEFINITION_NAME, |
|
58 |
// PngStoreProviderParameters.class, PngStoreProvider.NAME+"Parameters.xml"); |
|
59 |
// try { |
|
60 |
// FileHelper.registerMetadataDefinition( |
|
61 |
// PngStoreProvider.METADATA_DEFINITION_NAME, |
|
62 |
// PngStoreProvider.class, PngStoreProvider.NAME+"Metadata.xml"); |
|
63 |
// } catch (MetadataException e) { |
|
64 |
// exs.add(e); |
|
65 |
// } |
|
66 |
// |
|
67 |
DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices(); |
|
68 |
// |
|
69 |
|
|
70 |
try { |
|
71 |
if (!dataman.getStoreProviders() |
|
72 |
.contains(MosaicStoreProvider.NAME)) { |
|
73 |
dataman.registerStoreProviderFactory( |
|
74 |
new MosaicStoreProviderFactory( |
|
75 |
MosaicStoreProvider.NAME, |
|
76 |
MosaicStoreProvider.DESCRIPTION)); |
|
77 |
} |
|
78 |
} catch (RuntimeException e) { |
|
79 |
exs.add(e); |
|
80 |
} |
|
81 |
|
|
82 |
//FIXME: Cambiar usando la factoria |
|
83 |
// try { |
|
84 |
// DALFileLocator.getFilesystemServerExplorerManager() |
|
85 |
// .registerProvider(MosaicStoreProvider.NAME, |
|
86 |
// MosaicStoreProvider.DESCRIPTION, |
|
87 |
// PngFileSystemServerProvider.class); |
|
88 |
// } catch (RuntimeException e) { |
|
89 |
// exs.add(e); |
|
90 |
// } |
|
91 |
|
|
92 |
if (exs.size() > 0) { |
|
93 |
throw new LibraryException(this.getClass(), exs); |
|
94 |
} |
|
95 |
} |
|
96 |
} |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/java/org/gvsig/mosaic/MosaicPageManager1.txt | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.mosaic; |
|
7 |
|
|
8 |
//import org.gvsig.mosaic.lib.impl.DefaultMosaicFile; |
|
9 |
import java.io.IOException; |
|
10 |
import java.nio.Buffer; |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
import java.util.logging.Level; |
|
15 |
import java.util.logging.Logger; |
|
16 |
import org.cresques.cts.IProjection; |
|
17 |
import org.gvsig.fmap.dal.DataQuery; |
|
18 |
import org.gvsig.fmap.dal.exception.DataException; |
|
19 |
import org.gvsig.fmap.dal.raster.BandDescriptor; |
|
20 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
21 |
import org.gvsig.fmap.dal.raster.impl.DefaultRasterStore; |
|
22 |
import org.gvsig.fmap.geom.Geometry; |
|
23 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
24 |
import org.gvsig.fmap.geom.GeometryManager; |
|
25 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
26 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
27 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
28 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
29 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
30 |
import org.gvsig.fmap.geom.primitive.Point; |
|
31 |
import org.gvsig.mosaic.lib.api.MosaicTile; |
|
32 |
import org.gvsig.mosaic.lib.api.MosaicTiles; |
|
33 |
import org.gvsig.mosaic.lib.impl.DefaultMosaicFile; |
|
34 |
//import org.gvsig.mosaic.lib.impl.DefaultMosaicFile.Tile; |
|
35 |
//import org.gvsig.mosaic.lib.impl.DefaultTile; |
|
36 |
import org.gvsig.raster.lib.buffer.api.Band; |
|
37 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
38 |
import org.gvsig.raster.lib.buffer.api.BandTileManager; |
|
39 |
import org.gvsig.raster.lib.buffer.api.BufferDimensions; |
|
40 |
import org.gvsig.raster.lib.buffer.api.BufferLocator; |
|
41 |
import org.gvsig.raster.lib.buffer.api.BufferManager; |
|
42 |
import org.gvsig.raster.lib.buffer.api.NoData; |
|
43 |
import org.gvsig.raster.lib.buffer.api.TileStruct; |
|
44 |
import org.gvsig.raster.lib.buffer.api.exceptions.BandException; |
|
45 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException; |
|
46 |
import org.gvsig.tools.locator.LocatorException; |
|
47 |
|
|
48 |
/** |
|
49 |
* |
|
50 |
* @author osc |
|
51 |
*/ |
|
52 |
public class MosaicPageManager implements BandTileManager { |
|
53 |
private final int numBand; |
|
54 |
private final int bandType; |
|
55 |
private final DefaultMosaicFile mosaic; |
|
56 |
private Envelope envelope; // cuano se abre el envelope viene de los params createWLDEnvelope |
|
57 |
private final int rows; |
|
58 |
private final int cols; |
|
59 |
// private final int rowsPerTile; |
|
60 |
// private final int columnsPerTile; |
|
61 |
private final NoData noData; |
|
62 |
private final MosaicTiles mosaicTiles; |
|
63 |
private final Object values; |
|
64 |
private final TileStruct tileStruct; |
|
65 |
private final List<BandInfo> tileBandsInfo; |
|
66 |
|
|
67 |
/** |
|
68 |
* |
|
69 |
* @param numBand |
|
70 |
* @param bandType |
|
71 |
* @param rows |
|
72 |
* @param cols |
|
73 |
*/ |
|
74 |
public MosaicPageManager(DefaultMosaicFile mosaic, int numBand, int bandType) { |
|
75 |
this.numBand = numBand; |
|
76 |
this.bandType = bandType; |
|
77 |
this.mosaic = mosaic; |
|
78 |
this.mosaicTiles = this.mosaic.getTiles(); |
|
79 |
this.rows = mosaic.getRows(); |
|
80 |
this.cols = mosaic.getCols(); |
|
81 |
this.noData = BufferLocator.getBufferManager().createNoData(-99999, this.bandType); |
|
82 |
this.values = null; |
|
83 |
this.envelope = null; |
|
84 |
this.tileStruct = mosaic.getTileStruct(); |
|
85 |
this.tileBandsInfo = mosaic.getBandsInfo(); |
|
86 |
|
|
87 |
BandInfo bandInfo = BufferLocator.getBufferManager().createBandInfo(numBand, "MosaicBand_"+numBand, "Mosaic Band", bandType, (List<Map.Entry<Object, Object>>) values); |
|
88 |
try { |
|
89 |
this.envelope = GeometryLocator.getGeometryManager().createEnvelope(bandType); |
|
90 |
for (MosaicTile mosaicTile : mosaicTiles) { |
|
91 |
// TODO OSC: wld?? |
|
92 |
//List<String> wldParams = (List<String>) rasterStore.getParameters().getDynValue("wldParams"); |
|
93 |
DefaultRasterStore rasterStore = mosaicTile.getStore(); |
|
94 |
Envelope env = rasterStore.getEnvelope(); |
|
95 |
this.envelope.add(env); |
|
96 |
} |
|
97 |
} catch (CreateEnvelopeException | DataException | LocatorException ex) { |
|
98 |
this.envelope = null; |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* |
|
104 |
* @param row |
|
105 |
* @param col |
|
106 |
* @param dataType |
|
107 |
*/ |
|
108 |
@Override |
|
109 |
public Band load(int row, int col, int dataType) { |
|
110 |
// Crear envelope del tile correspondiente |
|
111 |
// Envelope del manager lo divide |
|
112 |
double w = this.tileStruct.getEnvelope().getGeometry().getBounds().getWidth(); |
|
113 |
double h = this.tileStruct.getEnvelope().getGeometry().getBounds().getHeight(); |
|
114 |
|
|
115 |
Point coordinates = this.tileStruct.getEnvelope().getUpperCorner(); |
|
116 |
double xCoord = coordinates.getX(); |
|
117 |
double yCoord = coordinates.getY(); |
|
118 |
|
|
119 |
Double pixelSize = this.tileStruct.getPixelSizePerZoomLevel().get(0); //TODO pixel size del primer zoom |
|
120 |
double xTileSize = this.getColumnsPerTile()*pixelSize; |
|
121 |
double yTileSize = this.getRowsPerTile()*pixelSize; |
|
122 |
double newX = xCoord + (xTileSize*col); |
|
123 |
double newY = yCoord + (yTileSize*row); |
|
124 |
Point newUpperPoint = null; |
|
125 |
Point newLowerCorner = null; |
|
126 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
127 |
try { |
|
128 |
|
|
129 |
newUpperPoint = geometryManager.createPoint(newX, newY, dataType); |
|
130 |
newLowerCorner = geometryManager.createPoint(xTileSize+newX, yTileSize-newY, dataType); |
|
131 |
} catch (CreateGeometryException ex) { |
|
132 |
throw new RuntimeException("Not able to create points for the new query envelope"); |
|
133 |
} |
|
134 |
|
|
135 |
Envelope envelopeQuery = null; |
|
136 |
try { |
|
137 |
envelopeQuery = geometryManager.createEnvelope(dataType); |
|
138 |
envelopeQuery.setUpperCorner(newUpperPoint); |
|
139 |
envelopeQuery.setLowerCorner(newLowerCorner); |
|
140 |
|
|
141 |
} catch (CreateEnvelopeException ex) { |
|
142 |
throw new RuntimeException("Not able to create new query envelope"); |
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
BufferManager bufferManager = BufferLocator.getBufferManager(); |
|
148 |
// int dataTypeSize = bufferManager.getDataTypeSize(dataType); |
|
149 |
// Calculo tiles |
|
150 |
//byte[][] byteArray = new byte[getRowsPerTile()*getColumnsPerTile()][]; |
|
151 |
Band band; |
|
152 |
try { |
|
153 |
band = bufferManager.createBand(dataType, this.getRowsPerTile(), this.getColumnsPerTile(), this.noData, this); |
|
154 |
} catch (BandException ex) { |
|
155 |
return null; |
|
156 |
} |
|
157 |
// |
|
158 |
fillBandNone(band); //TODO eliminar |
|
159 |
fillBand(band, envelopeQuery,pixelSize); |
|
160 |
return band; |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* |
|
165 |
* @param band |
|
166 |
* @param envelopeQuery |
|
167 |
* @return |
|
168 |
*/ |
|
169 |
public Band fillBand(Band band, Envelope envelopeQuery, double pixelSize) { |
|
170 |
int bRows = band.getRows(); |
|
171 |
int bCols = band.getColumns(); |
|
172 |
// BufferManager bufferManager = BufferLocator.getBufferManager(); |
|
173 |
// BufferDimensions newDimensions = bufferManager.createBufferDimensions(bRows, bCols, envelopeQuery); |
|
174 |
int[] bandDataTypes = null; |
|
175 |
bandDataTypes[0] = band.getDataType(); |
|
176 |
IProjection projection = envelopeQuery.getGeometry().getProjection(); |
|
177 |
// try { |
|
178 |
// //org.gvsig.raster.lib.buffer.api.Buffer newBuffer = bufferManager.createBuffer(bRows, bCols, bandDataTypes, projection); |
|
179 |
// } catch (BufferException ex) { |
|
180 |
// throw new RuntimeException("Not able to create buffer"); |
|
181 |
// } |
|
182 |
|
|
183 |
for (int i = 0; i < mosaicTiles.size(); i++) { |
|
184 |
MosaicTile tile = mosaicTiles.get(i); |
|
185 |
|
|
186 |
|
|
187 |
DefaultRasterStore tileStore = tile.getStore(); |
|
188 |
|
|
189 |
int numTileBand = this.tileBandsInfo.get(i).getBand(); |
|
190 |
BandDescriptor tileBand = tileStore.getBandDescriptor(numTileBand); // banda corresponde a cada tile en este pagemanager |
|
191 |
DataQuery dataQuery = null; |
|
192 |
Envelope tileStoreEnvelope = null; |
|
193 |
try { |
|
194 |
tileStoreEnvelope = tileStore.getEnvelope(); |
|
195 |
} catch (Exception ex) { |
|
196 |
tileStoreEnvelope = null; |
|
197 |
} |
|
198 |
Geometry interEnvelope = null; |
|
199 |
if (tileStoreEnvelope.intersects(envelopeQuery)) { |
|
200 |
try { |
|
201 |
interEnvelope = tileStoreEnvelope.getGeometry().intersection(envelopeQuery.getGeometry()); |
|
202 |
} catch (Exception ex) { |
|
203 |
} |
|
204 |
} |
|
205 |
if (interEnvelope==null) { |
|
206 |
continue; |
|
207 |
} else { |
|
208 |
//fill band with this part of the interEnvelope |
|
209 |
//find col of the tile to fill band |
|
210 |
int x0cols = (int) Math.ceil((interEnvelope.getBounds().getMinX()-envelopeQuery.getUpperCorner().getX())/pixelSize); |
|
211 |
// int x1cols = (int) (Math.ceil(interEnvelope.getBounds().getMinX()-envelopeQuery.getLowerCorner().getX())/pixelSize)); |
|
212 |
int x1cols = (int) Math.ceil((interEnvelope.getBounds().getMinX()-envelopeQuery.getLowerCorner().getX())/pixelSize); |
|
213 |
// int y0cols = (int) Math.ceil((envelopeQuery.getUpperCorner()-interEnvelope.getBounds().getMaxY())/pixelSize)); |
|
214 |
|
|
215 |
int x0rows = (int) Math.ceil((envelopeQuery.getUpperCorner().getY() - interEnvelope.getBounds().getMaxY())/pixelSize); |
|
216 |
int x1rows = (int) Math.ceil((envelopeQuery.getUpperCorner().getY() - interEnvelope.getBounds().getMinY())/pixelSize); |
|
217 |
|
|
218 |
Band getBand; |
|
219 |
try { |
|
220 |
getBand = tileStore.getRasterSet().getBand(numTileBand); |
|
221 |
} catch (DataException ex) { |
|
222 |
throw new RuntimeException("Not able to get the band"); |
|
223 |
} |
|
224 |
Object[] rowTileArray = new Object[getRowsPerTile()]; |
|
225 |
Object[] newRowTileArray = new Object[x1cols-x0cols]; |
|
226 |
//falta calcular hasta cual row |
|
227 |
|
|
228 |
for (int j = x0rows; j < x1rows; j++) { |
|
229 |
getBand.fetchRow(j, rowTileArray); |
|
230 |
System.arraycopy(newRowTileArray, 0, rowTileArray, x0cols, x1cols); |
|
231 |
band.putRow(j, newRowTileArray); |
|
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
return band; |
|
236 |
} |
|
237 |
public void fillBandNone(Band band) { |
|
238 |
for (int i = 0; i < band.getRows(); i++) { |
|
239 |
for (int j = 0; j < band.getColumns(); j++) { |
|
240 |
band.set(i, j, this.noData); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
@Override |
|
245 |
public void save(Buffer buffer, int row, int rows, int col, int cols, int dataType) throws IOException { |
|
246 |
// |
|
247 |
} |
|
248 |
|
|
249 |
@Override |
|
250 |
public BandInfo getBandInfo() { |
|
251 |
return null; |
|
252 |
} |
|
253 |
|
|
254 |
@Override |
|
255 |
public int getRowsPerTile() { |
|
256 |
return this.mosaic.getTileStruct().getRowsPerTile(); |
|
257 |
} |
|
258 |
|
|
259 |
@Override |
|
260 |
public int getColumnsPerTile() { |
|
261 |
return this.mosaic.getTileStruct().getColumnsPerTile(); |
|
262 |
} |
|
263 |
|
|
264 |
@Override |
|
265 |
public TileStruct getTileStruct() { |
|
266 |
return this.tileStruct; |
|
267 |
} |
|
268 |
|
|
269 |
@Override |
|
270 |
public boolean isSupportedSave() { |
|
271 |
return false; |
|
272 |
} |
|
273 |
|
|
274 |
@Override |
|
275 |
public void dispose() { |
|
276 |
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
277 |
} |
|
278 |
} |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/java/org/gvsig/mosaic/MosaicPageManager.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.mosaic; |
|
7 |
|
|
8 |
import java.io.IOException; |
|
9 |
import java.nio.Buffer; |
|
10 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
11 |
import org.gvsig.mosaic.lib.api.MosaicFile; |
|
12 |
import org.gvsig.raster.lib.buffer.api.Band; |
|
13 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
14 |
import org.gvsig.raster.lib.buffer.api.BandTileManager; |
|
15 |
import org.gvsig.raster.lib.buffer.api.TileStruct; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @author osc |
|
20 |
*/ |
|
21 |
public class MosaicPageManager implements BandTileManager { |
|
22 |
private final MosaicFile mosaic; |
|
23 |
// private final int rows; |
|
24 |
// private final int cols; |
|
25 |
private final int rowsPerTile; |
|
26 |
private final int columnsPerTile; |
|
27 |
private final int numBand; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @param numBand |
|
32 |
* @param bandType |
|
33 |
* @param rows |
|
34 |
* @param cols |
|
35 |
*/ |
|
36 |
public MosaicPageManager(MosaicFile mosaic, int numBand, int bandType, int rowsPerTile, int columnsPerTile) { |
|
37 |
this.mosaic = mosaic; |
|
38 |
this.numBand = numBand; |
|
39 |
this.rowsPerTile = rowsPerTile; |
|
40 |
this.columnsPerTile = columnsPerTile; |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
* @param row |
|
46 |
* @param col |
|
47 |
* @param dataType |
|
48 |
*/ |
|
49 |
@Override |
|
50 |
public Band load(int row, int col, int dataType) { |
|
51 |
Envelope envelope = this.mosaic.getEnvelope( |
|
52 |
col*columnsPerTile, |
|
53 |
row*rowsPerTile, |
|
54 |
columnsPerTile, |
|
55 |
rowsPerTile |
|
56 |
); |
|
57 |
|
|
58 |
Band band = this.mosaic.getBufferBand(envelope,this.numBand); |
|
59 |
return band; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public void save(Buffer buffer, int row, int rows, int col, int cols, int dataType) throws IOException { |
|
64 |
// |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public BandInfo getBandInfo() { |
|
69 |
return null; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public int getRowsPerTile() { |
|
74 |
return this.rowsPerTile; |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public int getColumnsPerTile() { |
|
79 |
return this.columnsPerTile; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public TileStruct getTileStruct() { |
|
84 |
return null; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public boolean isSupportedSave() { |
|
89 |
return false; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public void dispose() { |
|
94 |
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
95 |
} |
|
96 |
|
|
97 |
private Envelope calculateEnvelopeForTile(int row, int col) { |
|
98 |
return null; |
|
99 |
} |
|
100 |
} |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/java/org/gvsig/mosaic/MosaicStoreProvider.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.mosaic; |
|
7 |
|
|
8 |
//import org.gvsig.mosaic.lib.impl.DefaultMosaicFile; |
|
9 |
import java.awt.Image; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Collection; |
|
12 |
import java.util.Iterator; |
|
13 |
import java.util.List; |
|
14 |
import org.apache.commons.io.FilenameUtils; |
|
15 |
import org.cresques.cts.IProjection; |
|
16 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
17 |
import org.gvsig.fmap.dal.DataStore; |
|
18 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
19 |
import org.gvsig.fmap.dal.FileHelper; |
|
20 |
import org.gvsig.fmap.dal.exception.CloseException; |
|
21 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
22 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
23 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
24 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
25 |
import org.gvsig.fmap.dal.raster.BandDescriptor; |
|
26 |
import org.gvsig.fmap.dal.raster.BandQuery; |
|
27 |
import org.gvsig.fmap.dal.raster.RasterStore; |
|
28 |
import org.gvsig.fmap.dal.raster.spi.AbstractRasterStoreProvider; |
|
29 |
import org.gvsig.fmap.dal.raster.spi.BandDescriptorServices; |
|
30 |
import org.gvsig.fmap.dal.raster.spi.RasterStoreProvider; |
|
31 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
|
32 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
33 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
34 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
35 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
36 |
import org.gvsig.mosaic.lib.api.MosaicFile; |
|
37 |
import org.gvsig.mosaic.lib.api.MosaicLocator; |
|
38 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
|
39 |
import org.gvsig.raster.lib.buffer.api.BufferDimensions; |
|
40 |
import org.gvsig.raster.lib.buffer.api.TileStruct; |
|
41 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException; |
|
42 |
import org.gvsig.timesupport.Interval; |
|
43 |
import org.gvsig.tools.dynobject.DynClass; |
|
44 |
import org.gvsig.tools.dynobject.DynObject; |
|
45 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
|
46 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
47 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
48 |
import org.gvsig.raster.lib.buffer.api.BufferLocator; |
|
49 |
import org.gvsig.raster.lib.buffer.api.BufferManager; |
|
50 |
import org.gvsig.raster.lib.buffer.api.NoData; |
|
51 |
import org.gvsig.raster.lib.buffer.api.PageManager; |
|
52 |
|
|
53 |
|
|
54 |
/** |
|
55 |
* |
|
56 |
* @author osc |
|
57 |
*/ |
|
58 |
|
|
59 |
public final class MosaicStoreProvider extends AbstractRasterStoreProvider { |
|
60 |
public static String NAME = "MosaicStore"; |
|
61 |
public static String DESCRIPTION = "Mosaic store provider"; |
|
62 |
public static final String METADATA_DEFINITION_NAME = NAME; |
|
63 |
|
|
64 |
public static final String MOSAIC_COLS = "cols"; |
|
65 |
public static final String MOSAIC_ROWS = "rows"; |
|
66 |
public static final String MOSAIC_TILES = "tiles"; |
|
67 |
public static final String MOSAIC_BANDTILES = "bandTiles"; |
|
68 |
public static final String MOSAIC_ENVELOPE = "envelope"; |
|
69 |
public static final String MOSAIC_TILESPARAMETERS = "tilesParameters"; |
|
70 |
public static final String MOSAIC_BANDTYPES = "bandTypes"; |
|
71 |
|
|
72 |
private List<MosaicFile> tilesParameters; |
|
73 |
private List<RasterStore> tilesStore; // almacena los tilesStore |
|
74 |
private Envelope envelope; // cuano se abre el envelope viene de los params createWLDEnvelope |
|
75 |
private TileStruct tileStruct; |
|
76 |
private List<PageManager> pageManagers; //una por cada banda. los crea el init |
|
77 |
|
|
78 |
private int rows; |
|
79 |
private int cols; |
|
80 |
//private List<MosaicInfo> mosaicInfo; //info de los datos de cada pagemanagers |
|
81 |
private MosaicStoreProviderParameters params; |
|
82 |
private DataStoreProviderServices providerServices; |
|
83 |
// private final List bandTiles; |
|
84 |
// private final List<Integer> bandTypes; |
|
85 |
private int numBands; |
|
86 |
private BufferDimensions dimensions; |
|
87 |
private MosaicFile mosaicFile; |
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
public MosaicStoreProvider(MosaicStoreProviderParameters params, DataStoreProviderServices providerServices) throws InitializeException { //int rows, int cols, List<RasterStore> tilesStore ) { |
|
94 |
super(params, providerServices, FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME)); |
|
95 |
this.params = params; |
|
96 |
this.providerServices = providerServices; |
|
97 |
this.dimensions = null; |
|
98 |
} |
|
99 |
|
|
100 |
//MosaicStoreProvider(MosaicStoreProviderParameters mosaicStoreProviderParameters, DataStoreProviderServices providerServices) { |
|
101 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
102 |
//} |
|
103 |
public List<MosaicFile> getTilesParameters() { |
|
104 |
return tilesParameters; |
|
105 |
} |
|
106 |
|
|
107 |
public void setTilesParameters(List<MosaicFile> tilesParameters) { |
|
108 |
this.tilesParameters = tilesParameters; |
|
109 |
} |
|
110 |
|
|
111 |
public List<RasterStore> getTilesStore() { |
|
112 |
return tilesStore; |
|
113 |
} |
|
114 |
|
|
115 |
public void setTilesStore(List<RasterStore> tilesStore) { |
|
116 |
this.tilesStore = tilesStore; |
|
117 |
} |
|
118 |
|
|
119 |
public Envelope getEnvelope() { |
|
120 |
// this.getParameters().get |
|
121 |
return this.envelope; |
|
122 |
} |
|
123 |
|
|
124 |
public void setEnvelope(Envelope envelope) { |
|
125 |
this.envelope = envelope; |
|
126 |
} |
|
127 |
|
|
128 |
public List<PageManager> getPageManagers() { |
|
129 |
|
|
130 |
return this.pageManagers; |
|
131 |
} |
|
132 |
|
|
133 |
public void setPageManagers(List<PageManager> pageManagers) { |
|
134 |
this.pageManagers = pageManagers; |
|
135 |
} |
|
136 |
|
|
137 |
public int getRows() { |
|
138 |
return this.rows; |
|
139 |
} |
|
140 |
|
|
141 |
public void setRows(int rows) { |
|
142 |
this.rows = rows; |
|
143 |
} |
|
144 |
|
|
145 |
public int getCols() { |
|
146 |
return cols; |
|
147 |
} |
|
148 |
|
|
149 |
public void setCols(int cols) { |
|
150 |
this.cols = cols; |
|
151 |
} |
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
@Override |
|
156 |
public TileStruct getTileStruct() { |
|
157 |
if (true) { |
|
158 |
return null; |
|
159 |
} |
|
160 |
// List<Double> pixelSizes = new ArrayList<>(); |
|
161 |
// Map<Integer, Double> zoomLevels = new HashMap<Integer, Double>(); |
|
162 |
// |
|
163 |
// if (this.tileStruct == null) { |
|
164 |
// |
|
165 |
// tileStruct = new DefaultTileStruct(); |
|
166 |
// |
|
167 |
// int completeRows =(int) this.getEnvelope().getGeometry().getBounds().getHeight(); //getRaster().getHeight(); |
|
168 |
// int completeColumns = (int) this.getEnvelope().getGeometry().getBounds().getWidth();//getRaster().getWidth(); |
|
169 |
// double completePixelSizeX = this.getEnvelope().getLength(Geometry.DIMENSIONS.X) / completeColumns; |
|
170 |
// double completePixelSizeY = this.getEnvelope().getLength(Geometry.DIMENSIONS.Y) / completeRows; |
|
171 |
// |
|
172 |
// int maximumLength = completeColumns; |
|
173 |
// int tileMaximumLength = tileStruct.getColumnsPerTile(); // tileSizeX; |
|
174 |
// double maximumPixelSize = completePixelSizeX; |
|
175 |
// |
|
176 |
// if (completeRows * tileStruct.getRowsPerTile() > completeColumns * tileStruct.getColumnsPerTile()) { |
|
177 |
// maximumLength = completeRows; |
|
178 |
// tileMaximumLength = tileStruct.getRowsPerTile(); |
|
179 |
// maximumPixelSize = completePixelSizeY; |
|
180 |
// } |
|
181 |
// |
|
182 |
// double pixelSize = maximumPixelSize; |
|
183 |
// while (maximumLength * maximumPixelSize / pixelSize > tileMaximumLength) { |
|
184 |
// pixelSizes.add(pixelSize); |
|
185 |
// pixelSize = pixelSize * 2; |
|
186 |
// } |
|
187 |
// pixelSizes.add(pixelSize); |
|
188 |
// int i = 0; |
|
189 |
// for (int zoomLevel = pixelSizes.size() - 1; zoomLevel >= 0; zoomLevel--) { |
|
190 |
// zoomLevels.put(i, pixelSizes.get(zoomLevel)); |
|
191 |
// i++; |
|
192 |
// } |
|
193 |
// } |
|
194 |
// |
|
195 |
// return tileStruct; |
|
196 |
return null; |
|
197 |
} |
|
198 |
|
|
199 |
@Override |
|
200 |
public Image getImageLegend() { |
|
201 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
202 |
} |
|
203 |
|
|
204 |
@Override |
|
205 |
public MosaicStoreProviderParameters getParameters() { |
|
206 |
return this.params; |
|
207 |
} |
|
208 |
|
|
209 |
@Override |
|
210 |
public BufferDimensions getDimensions() { |
|
211 |
if(this.dimensions==null){ |
|
212 |
//this.dimensions = BufferLocator.getBufferManager().createBufferDimensions(this.getRaster().getHeight(), this.getRaster().getWidth(), this.envelope); |
|
213 |
//this.dimensions = BufferLocator.getBufferManager().createBufferDimensions(this.getRaster().getHeight(), this.getRaster().getWidth(), this.envelope); |
|
214 |
return this.mosaicFile.getDimensions(); |
|
215 |
} |
|
216 |
return this.dimensions; |
|
217 |
} |
|
218 |
|
|
219 |
@Override |
|
220 |
public boolean isTiled() { |
|
221 |
return true; |
|
222 |
} |
|
223 |
|
|
224 |
@Override |
|
225 |
public Iterator getChilds() { |
|
226 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
227 |
} |
|
228 |
|
|
229 |
@Override |
|
230 |
public DataServerExplorer getExplorer() throws ReadException, ValidateDataParametersException { |
|
231 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
232 |
} |
|
233 |
|
|
234 |
// |
|
235 |
// @Override |
|
236 |
// public void open() throws OpenException { |
|
237 |
// |
|
238 |
// } |
|
239 |
// |
|
240 |
// @Override |
|
241 |
// public void close() throws CloseException { |
|
242 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
243 |
// } |
|
244 |
// |
|
245 |
// @Override |
|
246 |
// public ResourceProvider getResource() { |
|
247 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
248 |
// } |
|
249 |
// |
|
250 |
// @Override |
|
251 |
// public void refresh() throws OpenException, InitializeException { |
|
252 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
253 |
// } |
|
254 |
// |
|
255 |
// @Override |
|
256 |
// public Object getSourceId() { |
|
257 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
258 |
// } |
|
259 |
// |
|
260 |
@Override |
|
261 |
public String getProviderName() { |
|
262 |
return NAME; |
|
263 |
} |
|
264 |
|
|
265 |
@Override |
|
266 |
public String getName() { |
|
267 |
return FilenameUtils.getBaseName(this.getParameters().getFile().getName()); |
|
268 |
} |
|
269 |
|
|
270 |
@Override |
|
271 |
public String getFullName() { |
|
272 |
return this.getParameters().getFile().getAbsolutePath(); |
|
273 |
} |
|
274 |
// |
|
275 |
// @Override |
|
276 |
// public Interval getInterval() { |
|
277 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
278 |
// } |
|
279 |
// |
|
280 |
// @Override |
|
281 |
// public Collection getTimes() { |
|
282 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
283 |
// } |
|
284 |
// |
|
285 |
// @Override |
|
286 |
// public Collection getTimes(Interval interval) { |
|
287 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
288 |
// } |
|
289 |
// |
|
290 |
// @Override |
|
291 |
// public boolean hasDynMethod(String name) { |
|
292 |
// return this.params.hasDynValue(name); |
|
293 |
// } |
|
294 |
// |
|
295 |
// @Override |
|
296 |
// public DynClass getDynClass() { |
|
297 |
// return this.params.getDynClass(); |
|
298 |
// } |
|
299 |
// |
|
300 |
// @Override |
|
301 |
// public void implement(DynClass dynClass) { |
|
302 |
// this.params.implement(dynClass); |
|
303 |
// } |
|
304 |
// |
|
305 |
// @Override |
|
306 |
// public void delegate(DynObject dynObject) { |
|
307 |
// } |
|
308 |
// |
|
309 |
// @Override |
|
310 |
// public Object getDynValue(String name) throws DynFieldNotFoundException { |
|
311 |
// return this.params.getDynValue(name); |
|
312 |
// } |
|
313 |
// |
|
314 |
// @Override |
|
315 |
// public void setDynValue(String name, Object value) throws DynFieldNotFoundException { |
|
316 |
// this.params.setDynValue(name, value); |
|
317 |
// } |
|
318 |
// |
|
319 |
// @Override |
|
320 |
// public boolean hasDynValue(String name) { |
|
321 |
// return this.params.hasDynValue(name); |
|
322 |
// } |
|
323 |
// |
|
324 |
// @Override |
|
325 |
// public Object invokeDynMethod(String name, Object[] args) throws DynMethodException { |
|
326 |
// return this.params.invokeDynMethod(name, args); |
|
327 |
// } |
|
328 |
// |
|
329 |
// @Override |
|
330 |
// public Object invokeDynMethod(int code, Object[] args) throws DynMethodException { |
|
331 |
// return this.params.invokeDynMethod(code, args); |
|
332 |
// } |
|
333 |
// |
|
334 |
// @Override |
|
335 |
// public void clear() { |
|
336 |
// this.params.clear(); |
|
337 |
// } |
|
338 |
// |
|
339 |
// @Override |
|
340 |
// public void dispose() { |
|
341 |
// |
|
342 |
// } |
|
343 |
|
|
344 |
@Override |
|
345 |
public Buffer createBuffer(org.gvsig.fmap.dal.raster.RasterQuery rasterQuery) throws BufferException { |
|
346 |
//TODO |
|
347 |
Envelope clip = rasterQuery.getClip(); |
|
348 |
List<BandQuery> bands = rasterQuery.getBands(); // List of bandQuery |
|
349 |
double pixelSize = rasterQuery.getPixelSize(); |
|
350 |
int[] listBandDataTypes = new int[bands.size()]; |
|
351 |
NoData[] listNoDataTypes = new NoData[bands.size()]; |
|
352 |
|
|
353 |
for (int i = 0; i < bands.size(); i++) { |
|
354 |
BandQuery bandQuery = bands.get(i); |
|
355 |
|
|
356 |
listBandDataTypes[i] = bandQuery.getDescriptor().getDataType(); |
|
357 |
listNoDataTypes[i] = bandQuery.getDescriptor().getNoData(); |
|
358 |
|
|
359 |
} |
|
360 |
BufferManager bufferManager = BufferLocator.getBufferManager(); |
|
361 |
|
|
362 |
IProjection projection; |
|
363 |
// projection = clip.getGeometry().getProjection(); |
|
364 |
projection = this.mosaicFile.getCRS(); |
|
365 |
|
|
366 |
int nRows = (int) (clip.getGeometry().getBounds().getHeight() / pixelSize); |
|
367 |
int nCols = (int) (clip.getGeometry().getBounds().getWidth() / pixelSize); |
|
368 |
|
|
369 |
Buffer buffer = bufferManager.createBuffer(nRows, nCols, listBandDataTypes, listNoDataTypes, projection, clip, this.getPageManagers()); |
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
|
375 |
return buffer; |
|
376 |
} |
|
377 |
|
|
378 |
// |
|
379 |
// protected Envelope createWLDEnvelope(List<String> wldParams) { |
|
380 |
// double pixelSizeX=Double.valueOf(wldParams.get(0)); |
|
381 |
// double rotationAxisY = Double.valueOf(wldParams.get(1)); |
|
382 |
// double rotationAxisX = Double.valueOf(wldParams.get(2)); |
|
383 |
// double pixelSizeY = Double.valueOf(wldParams.get(3)); |
|
384 |
// double upperLeftPixelCenterCoordX = Double.valueOf(wldParams.get(4)); |
|
385 |
// double upperLeftPixelCenterCoordY = Double.valueOf(wldParams.get(5)); |
|
386 |
// |
|
387 |
// if (0.0 != rotationAxisX || 0.0 != rotationAxisY) { |
|
388 |
// |
|
389 |
// // "Rotation in wld file not implemented yet. It will be ignored"); |
|
390 |
// } |
|
391 |
// |
|
392 |
// double leftMostX = upperLeftPixelCenterCoordX - (pixelSizeX * 0.5); |
|
393 |
// double upperMostY = upperLeftPixelCenterCoordY - (pixelSizeY * 0.5); |
|
394 |
// double height=getRaster().getHeight()*pixelSizeY; |
|
395 |
// double width=getRaster().getWidth()*pixelSizeX; |
|
396 |
// |
|
397 |
// // double minX, double minY, double maxX, double maxY, int subType |
|
398 |
// try { |
|
399 |
// envelope = GeometryLocator.getGeometryManager().createEnvelope( |
|
400 |
// Math.min(leftMostX,leftMostX + width), |
|
401 |
// Math.min(upperMostY,upperMostY + height), |
|
402 |
// Math.max(leftMostX,leftMostX + width), |
|
403 |
// Math.max(upperMostY,upperMostY + height), |
|
404 |
// Geometry.SUBTYPES.GEOM2D); |
|
405 |
// } catch (LocatorException | CreateEnvelopeException e) { |
|
406 |
// throw new RuntimeException( |
|
407 |
// "Failed to create envelope from wld file with coords: minx:"+leftMostX+ |
|
408 |
// ", miny:"+upperMostY+", maxX: "+leftMostX + width+", maxY: "+upperMostY + height); |
|
409 |
// |
|
410 |
// } |
|
411 |
// |
|
412 |
// return envelope; |
|
413 |
// } |
|
414 |
|
|
415 |
// @Override |
|
416 |
// public org.gvsig.fmap.dal.raster.BandDescriptor getBandDescriptor(int band) { |
|
417 |
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
418 |
// } |
|
419 |
|
|
420 |
@Override |
|
421 |
public int getBands() { |
|
422 |
this.autoOpen(); |
|
423 |
return this.numBands; |
|
424 |
} |
|
425 |
|
|
426 |
@Override |
|
427 |
public void open() throws OpenException { |
|
428 |
if (this.mosaicFile!=null) { |
|
429 |
return; |
|
430 |
} |
|
431 |
this.mosaicFile = MosaicLocator.getMosaicManager().createMosaicFile(); |
|
432 |
this.mosaicFile.read(params.getFile()); |
|
433 |
|
|
434 |
this.pageManagers = new ArrayList(); |
|
435 |
// try { |
|
436 |
// this.envelope = GeometryLocator.getGeometryManager().createEnvelope(bandTypes.get(0)); |
|
437 |
// } catch (CreateEnvelopeException ex) { |
|
438 |
// throw new RuntimeException("Not able to create Envelope"); |
|
439 |
// } |
|
440 |
// tileStruct ??? |
|
441 |
//this.tileStruct = null; // TODO OSC: Example in AbstractAwtRasterStoreProvider |
|
442 |
// Add to tilesParameters |
|
443 |
// Add MosaicPageManager for each band |
|
444 |
// if (this.bandTiles.size()!=this.bandTypes.size()) { |
|
445 |
// throw new RuntimeException("Not valid sizes. bandTiles!=bandTypes"); |
|
446 |
// } |
|
447 |
// // TODO: meterlo en isvalid |
|
448 |
// if (this.mosaicFile.getTiles().size()!=this.mosaicFile.getBandsInfo().size()){ |
|
449 |
// throw new RuntimeException("Not valid sizes."); |
|
450 |
// } |
|
451 |
int n = 0; |
|
452 |
this.numBands = this.mosaicFile.getBandsInfo().size(); |
|
453 |
for (BandInfo bandInfo : this.mosaicFile.getBandsInfo()) { |
|
454 |
// each size bandInfo == 1 mosaic band |
|
455 |
int iBandNumber = bandInfo.getBand(); |
|
456 |
int bandType = bandInfo.getDataType(); |
|
457 |
MosaicPageManager mosaicPageManager = new MosaicPageManager(mosaicFile, iBandNumber, bandType, 256, 256); |
|
458 |
this.pageManagers.add(mosaicPageManager); |
|
459 |
|
|
460 |
BandDescriptorServices bandDescriptor = this.getBandDescriptor(n); |
|
461 |
bandDescriptor.setName(bandInfo.getName()); |
|
462 |
bandDescriptor.setDescription(bandInfo.getDescription()); |
|
463 |
bandDescriptor.setDataType(bandInfo.getDataType()); |
|
464 |
} |
|
465 |
|
|
466 |
this.envelope = this.getDimensions().getEnvelope(); |
|
467 |
// try { |
|
468 |
// this.envelope = GeometryLocator.getGeometryManager().createEnvelope(Geometry.SUBTYPES.GEOM2D); |
|
469 |
// } catch (CreateEnvelopeException ex) { |
|
470 |
// throw new RuntimeException("Not able to create provider envelope"); |
|
471 |
// } |
|
472 |
// for (MosaicTile tile : this.mosaicFile.getTiles()) { |
|
473 |
// try { |
|
474 |
// this.envelope.add(tile.getStore().getEnvelope()); |
|
475 |
// } catch (DataException | LocatorException | CreateEnvelopeException ex) { |
|
476 |
// throw new RuntimeException("Not able to get envelope from stores"); |
|
477 |
// } |
|
478 |
// } |
|
479 |
// if (this.tilesStore.size()!=bandTile.size()) { |
|
480 |
// throw new RuntimeException("Not valid sizes. tiles!=bandTiles"); |
|
481 |
// } |
|
482 |
// |
|
483 |
// //Param MosaicFile |
|
484 |
// MosaicFile mosaicFile = mosaicManager.createMosaicFile(); |
|
485 |
// MosaicTiles tiles = new DefaultMosaicTiles(mosaicFile); //todo creator |
|
486 |
// ArrayList bandTileInfo = new ArrayList(); |
|
487 |
// for (int j = 0; j < bandTile.size(); j++) { |
|
488 |
// int bandTileNumber = (int)bandTile.get(j); |
|
489 |
// if (bandTileNumber==-1) { |
|
490 |
// continue; |
|
491 |
// } |
|
492 |
// RasterStore rasterStore = this.tilesStore.get(j); |
|
493 |
// bandTileInfo.add(j); |
|
494 |
// tiles.add((OpenRasterStoreParameters) rasterStore.getParameters()); |
|
495 |
// //Param envelope |
|
496 |
// Envelope env; |
|
497 |
// try { |
|
498 |
// env = rasterStore.getEnvelope(); |
|
499 |
// } catch (Exception ex) { |
|
500 |
// env = null; |
|
501 |
// } |
|
502 |
// this.envelope.add(env); |
|
503 |
// } |
|
504 |
// mosaicFile.setTiles(tiles); |
|
505 |
// mosaicFile.setBandsInfo(bandTileInfo); // banda correspondiente al tile |
|
506 |
// //Params bandType |
|
507 |
//// Integer bandType = this.bandTypes.get(iBandNumber); |
|
508 |
// Integer bandType = this.mosaicFile.getTiles().get(iBandNumber).getStore().getBandDescriptor(iBandNumber).getDataType(); |
|
509 |
// // i => number corresponding to the new |
|
510 |
// mosaicFile.setRows(this.rows); |
|
511 |
// mosaicFile.setCols(this.cols); |
|
512 |
// mosaicFile.setTileStruct(this.getTileStruct()); |
|
513 |
// MosaicPageManager mosaicPageManager = new MosaicPageManager(mosaicFile, iBandNumber, bandType, 256, 256); |
|
514 |
// |
|
515 |
// |
|
516 |
// this.pageManagers.add(mosaicPageManager); |
|
517 |
// |
|
518 |
// } |
|
519 |
// this.numBands = this.mosaicFile.getTiles().size(); |
|
520 |
} |
|
521 |
|
|
522 |
@Override |
|
523 |
public ResourceProvider getResource() { |
|
524 |
return null; |
|
525 |
} |
|
526 |
|
|
527 |
@Override |
|
528 |
public Object getSourceId() { |
|
529 |
return this.getParameters().getFile(); |
|
530 |
} |
|
531 |
|
|
532 |
@Override |
|
533 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
|
534 |
if (DataStore.METADATA_CRS.equalsIgnoreCase(name)) { |
|
535 |
this.autoOpen(); |
|
536 |
return this.mosaicFile.getCRS(); |
|
537 |
|
|
538 |
} else if (DataStore.METADATA_ENVELOPE.equalsIgnoreCase(name)) { |
|
539 |
this.autoOpen(); |
|
540 |
return this.mosaicFile.getDimensions().getEnvelope(); |
|
541 |
|
|
542 |
} |
|
543 |
return super.getDynValue(name); |
|
544 |
} |
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
} |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/java/org/gvsig/mosaic/MosaicStoreProviderParameters.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.mosaic; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import org.gvsig.fmap.dal.FileHelper; |
|
10 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
|
11 |
import org.gvsig.fmap.dal.raster.spi.AbstractOpenRasterStoreParameters; |
|
12 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
13 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
14 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
15 |
|
|
16 |
/** |
|
17 |
* |
|
18 |
* @author osc |
|
19 |
*/ |
|
20 |
public class MosaicStoreProviderParameters |
|
21 |
extends AbstractOpenRasterStoreParameters |
|
22 |
implements OpenDataStoreParameters, FilesystemStoreParameters |
|
23 |
{ |
|
24 |
public static final String PARAMETERS_DEFINITION_NAME = "MosaicStoreProviderParameters"; |
|
25 |
public static final String PARAM_NAME_FILE = "mosaicFile"; |
|
26 |
private final DelegatedDynObject parameters; |
|
27 |
|
|
28 |
public MosaicStoreProviderParameters() { |
|
29 |
this(PARAMETERS_DEFINITION_NAME); |
|
30 |
} |
|
31 |
|
|
32 |
protected MosaicStoreProviderParameters(String parametersDefinitionName) { |
|
33 |
this(parametersDefinitionName, MosaicStoreProvider.NAME); |
|
34 |
} |
|
35 |
|
|
36 |
public MosaicStoreProviderParameters(String parametersDefinitionName, String name) { |
|
37 |
super(); |
|
38 |
this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName); |
|
39 |
this.parameters.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, parametersDefinitionName); //TODO no necesario? |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
44 |
return this.parameters; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public boolean isValid() { |
|
49 |
//comprobacion de parametros |
|
50 |
return true; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public File getFile() { |
|
55 |
return (File) this.parameters.getDynValue(PARAM_NAME_FILE); |
|
56 |
|
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public void setFile(File file) { |
|
61 |
this.parameters.setDynValue(PARAM_NAME_FILE, file); |
|
62 |
} |
|
63 |
|
|
64 |
|
|
65 |
} |
org.gvsig.mosaic/trunk/org.gvsig.mosaic/org.gvsig.mosaic.provider/src/main/java/org/gvsig/mosaic/MosaicStoreProviderFactory.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.mosaic; |
|
25 |
|
|
26 |
import java.io.IOException; |
|
27 |
import java.io.InputStream; |
|
28 |
import java.net.MalformedURLException; |
|
29 |
import java.util.Map; |
|
30 |
import java.util.logging.Level; |
|
31 |
import java.net.URL; |
|
32 |
import java.util.logging.Logger; |
|
33 |
|
|
34 |
import org.gvsig.fmap.dal.DataParameters; |
|
35 |
import org.gvsig.fmap.dal.FileHelper; |
|
36 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
37 |
import org.gvsig.fmap.dal.raster.spi.AbstractRasterStoreProviderFactory; |
|
38 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
39 |
import org.gvsig.tools.ToolsLocator; |
|
40 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
import org.xmlpull.v1.XmlPullParserException; |
|
43 |
|
|
44 |
/** |
|
45 |
* |
|
46 |
* @author osc |
|
47 |
*/ |
|
48 |
public class MosaicStoreProviderFactory extends AbstractRasterStoreProviderFactory { |
|
49 |
|
|
50 |
// private static final Logger logger = LoggerFactory.getLogger(MosaicStoreProviderFactory.class); |
|
51 |
// private final String idp = "MosaicStoreProviderParameters"; |
|
52 |
// private final String process = "MosaicStoreProviderParameters"; |
|
53 |
// private final String description = "Dyn for MosaicProvider"; |
|
54 |
// private final DynStruct definition; |
|
55 |
|
|
56 |
public MosaicStoreProviderFactory(String name, String description) { |
|
57 |
super(name, description); |
|
58 |
// |
|
59 |
// DynObjectManager dynObjectManager = ToolsLocator.getDynObjectManager(); |
|
60 |
// InputStream resource = this.getClass().getClassLoader().getResourceAsStream("org/gvsig/mosaic/dal/MosaicStoreParameters.xml"); |
|
61 |
// Map definitions = null; |
|
62 |
// try { |
|
63 |
// definitions = dynObjectManager.importDynClassDefinitions(resource, this.getClass().getClassLoader()); |
|
64 |
// } catch (XmlPullParserException ex) { |
|
65 |
// java.util.logging.Logger.getLogger(MosaicStoreProviderFactory.class.getName()).log(Level.SEVERE, null, ex); |
|
66 |
// } catch (IOException ex) { |
|
67 |
// java.util.logging.Logger.getLogger(MosaicStoreProviderFactory.class.getName()).log(Level.SEVERE, null, ex); |
|
68 |
// } |
|
69 |
// this.definition = (DynStruct) definitions.get("MosaicStoreProviderParameters"); |
|
70 |
//// |
|
71 |
//// //dynObjectManager.createDynClass(idp, process, description); |
|
72 |
//// URL fileURL = null; |
|
73 |
//// try { |
|
74 |
//// fileURL = new URL("org/gvsig/mosaic/dal/MosaicStoreParameters.xml"); |
|
75 |
//// } catch (MalformedURLException ex) { |
|
76 |
//// Logger.getLogger(MosaicStoreProviderFactory.class.getName()).log(Level.SEVERE, null, ex); |
|
77 |
//// } |
|
78 |
//// FileHelper.registerParametersDefinition( |
|
79 |
//// MosaicStoreProviderParameters.PARAMETERS_DEFINITION_NAME, |
|
80 |
//// MosaicStoreProviderParameters.class, |
|
81 |
//// this.getClass().getClassLoader(), |
|
82 |
//// fileURL); |
|
83 |
// } |
|
84 |
// |
|
85 |
// public DynStruct getDynDefinition() { |
|
86 |
// return this.definition; |
|
87 |
// } |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public MosaicStoreProvider createProvider(DataParameters parameters, |
|
92 |
DataStoreProviderServices providerServices) throws InitializeException { |
|
93 |
return new MosaicStoreProvider((MosaicStoreProviderParameters)parameters,providerServices); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* |
|
98 |
* @return |
|
99 |
*/ |
|
100 |
@Override |
|
101 |
public MosaicStoreProviderParameters createParameters() { |
|
102 |
return new MosaicStoreProviderParameters();//this.getDynDefinition().getName()); |
|
103 |
} |
|
104 |
|
|
105 |
} |
Also available in: Unified diff