Revision 174
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.main/src/test/resources/serie1.rmf | ||
---|---|---|
10 | 10 |
<Date>27/08/2005-02:36:00</Date> |
11 | 11 |
</Dates> |
12 | 12 |
</Serial> |
13 |
<Serial> |
|
14 |
<Name>Katrina2</Name> |
|
15 |
<Description>Evoluci?n del katrina en otra serie</Description> |
|
16 |
<Type>1</Type> |
|
17 |
<Dates> |
|
18 |
<Date>152322.0</Date> |
|
19 |
<Date>152400.0</Date> |
|
20 |
</Dates> |
|
21 |
</Serial> |
|
13 | 22 |
</Serials> |
14 | 23 |
</RasterMetaFile> |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.main/src/test/resources/serie2.rmf | ||
---|---|---|
9 | 9 |
<Date>28/08/2005-12:05:00</Date> |
10 | 10 |
</Dates> |
11 | 11 |
</Serial> |
12 |
<Serial> |
|
13 |
<Name>Katrina2</Name> |
|
14 |
<Description>Evoluci?n del katrina en otra serie</Description> |
|
15 |
<Type>0</Type> |
|
16 |
<Dates> |
|
17 |
<Date>152438.0</Date> |
|
18 |
</Dates> |
|
19 |
</Serial> |
|
12 | 20 |
</Serials> |
13 | 21 |
</RasterMetaFile> |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.main/src/test/resources/serie3.rmf | ||
---|---|---|
9 | 9 |
<Date>29/08/2005-12:00:00</Date> |
10 | 10 |
</Dates> |
11 | 11 |
</Serial> |
12 |
<Serial> |
|
13 |
<Name>Katrina2</Name> |
|
14 |
<Description>Evoluci?n del katrina en otra serie</Description> |
|
15 |
<Type>0</Type> |
|
16 |
<Dates> |
|
17 |
<Date>152550.0</Date> |
|
18 |
</Dates> |
|
19 |
</Serial> |
|
12 | 20 |
</Serials> |
13 | 21 |
</RasterMetaFile> |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/series/TestSaveSerialToRmf.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.fmap.dal.series; |
23 | 23 |
|
24 |
import java.io.File; |
|
24 | 25 |
import java.text.ParseException; |
25 | 26 |
|
26 | 27 |
import org.gvsig.fmap.dal.coverage.BaseTestCase; |
... | ... | |
58 | 59 |
} catch (Exception e) { |
59 | 60 |
e.printStackTrace(); |
60 | 61 |
} |
62 |
File a = new File(baseDir + "serie1.rmf"); |
|
63 |
if(a.exists()) |
|
64 |
a.delete(); |
|
65 |
a = new File(baseDir + "serie2.rmf"); |
|
66 |
if(a.exists()) |
|
67 |
a.delete(); |
|
68 |
a = new File(baseDir + "serie3.rmf"); |
|
69 |
if(a.exists()) |
|
70 |
a.delete(); |
|
61 | 71 |
|
62 | 72 |
try { |
63 | 73 |
f1 = manager.open(path1); |
... | ... | |
73 | 83 |
public void testStack() { |
74 | 84 |
SerialInfo serialInfo = null; |
75 | 85 |
try { |
76 |
serialInfo = f1.getSerialInfo(); |
|
77 |
//assertEquals(serialInfo.getName(), "Katrina"); |
|
78 |
//assertEquals(serialInfo.getDescription(), "Evoluci?n del katrina"); |
|
86 |
serialInfo = f1.getSerialInfo(); //Lo da vacio pq antes hemos borrado el rmf |
|
79 | 87 |
serialInfo.setName("Katrina"); |
80 | 88 |
serialInfo.setDescription("Evoluci?n del katrina"); |
81 |
serialInfo.removeIntervals(); |
|
82 | 89 |
serialInfo.createNewTimeInterval("25/8/2005-00:05:00", "27/8/2005-14:36:00"); |
83 |
f1.setSerialInfo(serialInfo); |
|
90 |
f1.setSerialInfo(serialInfo); //Salvamos la serie
|
|
84 | 91 |
|
92 |
serialInfo.setName("Katrina2"); |
|
93 |
serialInfo.setDescription("Evoluci?n del katrina en otra serie"); |
|
94 |
serialInfo.createNewTimeInterval(152322, 152400); |
|
95 |
f1.setSerialInfo(serialInfo); //Salvamos la serie |
|
96 |
|
|
97 |
//------------------------------------ |
|
98 |
|
|
85 | 99 |
serialInfo = f2.getSerialInfo(); |
86 |
//assertEquals(serialInfo.getName(), "Katrina"); |
|
87 |
//assertEquals(serialInfo.getDescription(), "Evoluci?n del katrina"); |
|
88 | 100 |
serialInfo.setName("Katrina"); |
89 | 101 |
serialInfo.setDescription("Evoluci?n del katrina"); |
90 |
serialInfo.removeIntervals(); |
|
91 | 102 |
serialInfo.createNewTimeValue("28/8/2005-00:05:00"); |
92 | 103 |
f2.setSerialInfo(serialInfo); |
93 | 104 |
|
105 |
serialInfo.setName("Katrina2"); |
|
106 |
serialInfo.setDescription("Evoluci?n del katrina en otra serie"); |
|
107 |
serialInfo.createNewTimeValue(152438); |
|
108 |
f2.setSerialInfo(serialInfo); //Salvamos la serie |
|
109 |
|
|
110 |
//------------------------------------ |
|
111 |
|
|
94 | 112 |
serialInfo = f3.getSerialInfo(); |
95 |
//assertEquals(serialInfo.getName(), "Katrina"); |
|
96 |
//assertEquals(serialInfo.getDescription(), "Evoluci?n del katrina"); |
|
97 | 113 |
serialInfo.setName("Katrina"); |
98 | 114 |
serialInfo.setDescription("Evoluci?n del katrina"); |
99 |
serialInfo.removeIntervals(); |
|
100 | 115 |
serialInfo.createNewTimeValue("29/8/2005"); |
101 | 116 |
f3.setSerialInfo(serialInfo); |
117 |
|
|
118 |
serialInfo.setName("Katrina2"); |
|
119 |
serialInfo.setDescription("Evoluci?n del katrina en otra serie"); |
|
120 |
serialInfo.createNewTimeValue(152550.0); |
|
121 |
f3.setSerialInfo(serialInfo); //Salvamos la serie |
|
122 |
|
|
102 | 123 |
} catch (RmfSerializerException e1) { |
103 | 124 |
// TODO Auto-generated catch block |
104 | 125 |
e1.printStackTrace(); |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.main/src/test/java/org/gvsig/fmap/dal/series/TestReadDataTDataStore.java | ||
---|---|---|
30 | 30 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
31 | 31 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
32 | 32 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
33 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
|
34 | 33 |
import org.gvsig.fmap.dal.coverage.exception.TimeException; |
35 | 34 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
36 | 35 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
37 | 36 |
import org.gvsig.fmap.dal.coverage.store.TRasterStore; |
38 |
import org.gvsig.fmap.dal.coverage.store.props.SerialInfo; |
|
39 | 37 |
import org.gvsig.raster.impl.datastruct.DefaultTimeInfo; |
40 | 38 |
import org.gvsig.raster.impl.store.DefaultTRasterStore; |
41 | 39 |
/** |
... | ... | |
79 | 77 |
} |
80 | 78 |
|
81 | 79 |
public void testStack() { |
82 |
SerialInfo serialInfo = null; |
|
83 | 80 |
try { |
84 |
serialInfo = f1.getSerialInfo(); |
|
85 |
serialInfo.setName("Katrina"); |
|
86 |
serialInfo.setDescription("Evoluci?n del katrina"); |
|
87 |
serialInfo.removeIntervals(); |
|
88 |
serialInfo.createNewTimeInterval("25/8/2005-00:05:00", "27/8/2005-14:36:00"); |
|
89 |
f1.setSerialInfo(serialInfo); |
|
90 |
|
|
91 |
serialInfo = f2.getSerialInfo(); |
|
92 |
serialInfo.setName("Katrina"); |
|
93 |
serialInfo.setDescription("Evoluci?n del katrina"); |
|
94 |
serialInfo.removeIntervals(); |
|
95 |
serialInfo.createNewTimeValue("28/8/2005-00:05:00"); |
|
96 |
f2.setSerialInfo(serialInfo); |
|
97 |
|
|
98 |
serialInfo = f3.getSerialInfo(); |
|
99 |
serialInfo.setName("Katrina"); |
|
100 |
serialInfo.setDescription("Evoluci?n del katrina"); |
|
101 |
serialInfo.removeIntervals(); |
|
102 |
serialInfo.createNewTimeValue("29/8/2005"); |
|
103 |
f3.setSerialInfo(serialInfo); |
|
104 |
|
|
105 | 81 |
TRasterStore store = new DefaultTRasterStore(f1); |
106 | 82 |
store.addDataStore(f2); |
107 | 83 |
store.addDataStore(f3); |
... | ... | |
109 | 85 |
//Selecci?n temporal por valor |
110 | 86 |
|
111 | 87 |
TimeInfo tInfo = new DefaultTimeInfo(); |
112 |
tInfo.addDate("29/8/2005"); //Blue
|
|
88 |
tInfo.addValue("29/8/2005"); //Blue
|
|
113 | 89 |
store.setTime(tInfo); |
114 | 90 |
|
115 |
RasterQuery query = manager.createQuery(); |
|
116 |
query.setAllDrawableBands(); |
|
117 |
try { |
|
118 |
query.setAreaOfInterest(0, 0, (int)store.getWidth(), (int)store.getHeight()); |
|
119 |
Buffer buf = store.query(query); |
|
120 |
byte[] data = new byte[3]; |
|
121 |
buf.getElemByte(0, 0, data); |
|
122 |
assertEquals(0, data[0]); |
|
123 |
assertEquals(0, data[1]); |
|
124 |
assertEquals(-1, data[2]); |
|
125 |
System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]); |
|
126 |
} catch (InvalidSetViewException e1) { |
|
127 |
e1.printStackTrace(); |
|
128 |
} catch (ProcessInterruptedException e) { |
|
129 |
e.printStackTrace(); |
|
130 |
} catch (RasterDriverException e) { |
|
131 |
e.printStackTrace(); |
|
132 |
} |
|
91 |
Buffer buf = readData(store); |
|
92 |
byte[] data = new byte[3]; |
|
93 |
buf.getElemByte(0, 0, data); |
|
94 |
assertEquals(0, data[0]); |
|
95 |
assertEquals(0, data[1]); |
|
96 |
assertEquals(-1, data[2]); |
|
97 |
System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]); |
|
133 | 98 |
|
99 |
|
|
134 | 100 |
//Selecci?n temporal por rango |
135 | 101 |
|
136 | 102 |
tInfo = new DefaultTimeInfo(); |
137 |
tInfo.addDate("26/8/2005-10:05:00"); //Red
|
|
138 |
tInfo.addDate("26/8/2005-12:36:00");
|
|
103 |
tInfo.addValue("26/8/2005-10:05:00"); //Red
|
|
104 |
tInfo.addValue("26/8/2005-12:36:00");
|
|
139 | 105 |
store.setTime(tInfo); |
140 | 106 |
|
141 |
try { |
|
142 |
query.setAreaOfInterest(0, 0, (int)store.getWidth(), (int)store.getHeight()); |
|
143 |
Buffer buf = store.query(query); |
|
144 |
byte[] data = new byte[3]; |
|
145 |
buf.getElemByte(0, 0, data); |
|
146 |
assertEquals(-1, data[0]); |
|
147 |
assertEquals(0, data[1]); |
|
148 |
assertEquals(0, data[2]); |
|
149 |
System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]); |
|
150 |
} catch (InvalidSetViewException e1) { |
|
151 |
e1.printStackTrace(); |
|
152 |
} catch (ProcessInterruptedException e) { |
|
153 |
e.printStackTrace(); |
|
154 |
} catch (RasterDriverException e) { |
|
155 |
e.printStackTrace(); |
|
156 |
} |
|
157 |
} catch (RmfSerializerException e1) { |
|
158 |
e1.printStackTrace(); |
|
107 |
buf = readData(store); |
|
108 |
data = new byte[3]; |
|
109 |
buf.getElemByte(0, 0, data); |
|
110 |
assertEquals(-1, data[0]); |
|
111 |
assertEquals(0, data[1]); |
|
112 |
assertEquals(0, data[2]); |
|
113 |
System.out.println("RGB:" + data[0] + ", " + data[1] + ", " + data[2]); |
|
114 |
|
|
159 | 115 |
} catch (ParseException e) { |
160 | 116 |
e.printStackTrace(); |
161 | 117 |
} catch (TimeException e) { |
... | ... | |
180 | 136 |
System.out.println("G:" + (buf1.getElemByte(0, 0, 1) & 0xff)); |
181 | 137 |
System.out.println("B:" + (buf1.getElemByte(0, 0, 2) & 0xff));*/ |
182 | 138 |
} |
139 |
|
|
140 |
private Buffer readData(TRasterStore store) { |
|
141 |
RasterQuery query = manager.createQuery(); |
|
142 |
query.setAllDrawableBands(); |
|
143 |
try { |
|
144 |
query.setAreaOfInterest(0, 0, (int)store.getWidth(), (int)store.getHeight()); |
|
145 |
return store.query(query); |
|
146 |
} catch (InvalidSetViewException e1) { |
|
147 |
e1.printStackTrace(); |
|
148 |
} catch (ProcessInterruptedException e) { |
|
149 |
e.printStackTrace(); |
|
150 |
} catch (RasterDriverException e) { |
|
151 |
e.printStackTrace(); |
|
152 |
} |
|
153 |
|
|
154 |
return null; |
|
155 |
} |
|
183 | 156 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/store/TRasterStore.java | ||
---|---|---|
86 | 86 |
* @param serialDescription |
87 | 87 |
*/ |
88 | 88 |
public void setSerialDescription(String serialDescription); |
89 |
|
|
90 |
/** |
|
91 |
* Selects a serial by name |
|
92 |
* @param serialName |
|
93 |
*/ |
|
94 |
public void selectSerial(String serialName); |
|
89 | 95 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/store/props/SerialInfo.java | ||
---|---|---|
30 | 30 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
31 | 31 |
*/ |
32 | 32 |
public interface SerialInfo { |
33 |
|
|
33 | 34 |
/** |
35 |
* Selects the serial |
|
36 |
* @param name |
|
37 |
*/ |
|
38 |
public void selectSerial(String name); |
|
39 |
|
|
40 |
/** |
|
41 |
* Selects the serial |
|
42 |
* @param pos |
|
43 |
*/ |
|
44 |
public void selectSerial(int pos); |
|
45 |
|
|
46 |
/** |
|
34 | 47 |
* Sets the description |
35 | 48 |
* @return |
36 | 49 |
*/ |
... | ... | |
70 | 83 |
public void createNewTimeInterval(String dateA, String dateB) throws ParseException; |
71 | 84 |
|
72 | 85 |
/** |
86 |
* Creates a new single value for the time. This method forces the use of |
|
87 |
* the numeric type. |
|
88 |
* @param value |
|
89 |
* @throws ParseException |
|
90 |
*/ |
|
91 |
public void createNewTimeValue(double value) throws ParseException; |
|
92 |
|
|
93 |
/** |
|
94 |
* Creates a pair of values for the time. This will represent a interval. This method |
|
95 |
* forces the use of the numeric type. |
|
96 |
* @param dateA |
|
97 |
* @param dateB |
|
98 |
* @throws ParseException |
|
99 |
*/ |
|
100 |
public void createNewTimeInterval(double a, double b) throws ParseException; |
|
101 |
|
|
102 |
/** |
|
73 | 103 |
* Removes all date intervals |
74 | 104 |
*/ |
75 | 105 |
public void removeIntervals(); |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/datastruct/TimeInfo.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import java.text.ParseException; |
25 | 25 |
import java.util.ArrayList; |
26 |
import java.util.Date; |
|
27 | 26 |
|
28 | 27 |
/** |
29 | 28 |
* Time information |
30 | 29 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
31 | 30 |
*/ |
32 | 31 |
public interface TimeInfo { |
32 |
public static final int NUMERIC = 0; |
|
33 |
public static final int DATE = 1; |
|
34 |
|
|
33 | 35 |
public static final int SINGLE_VALUES = 0; |
34 | 36 |
public static final int RANGES = 1; |
35 | 37 |
|
36 |
public void load(String[] t, int type) throws ParseException; |
|
37 |
|
|
38 | 38 |
/** |
39 | 39 |
* Gets the serial name |
40 | 40 |
* @return |
... | ... | |
51 | 51 |
* Gets the list of dates |
52 | 52 |
* @return |
53 | 53 |
*/ |
54 |
public ArrayList<Date> getTime();
|
|
54 |
public ArrayList<?> getTime();
|
|
55 | 55 |
|
56 | 56 |
/** |
57 | 57 |
* Sets the list of dates |
58 | 58 |
* @return |
59 | 59 |
*/ |
60 |
public void setTime(ArrayList<Date> time);
|
|
60 |
public void setTime(ArrayList<?> time);
|
|
61 | 61 |
|
62 | 62 |
/** |
63 | 63 |
* Gets the time type |
... | ... | |
78 | 78 |
public void setTimeType(String timeType); |
79 | 79 |
|
80 | 80 |
/** |
81 |
* Adds a new date in the array |
|
82 |
* @param dateStr |
|
81 |
* Gets the data type |
|
82 |
* @return |
|
83 |
*/ |
|
84 |
public int getDataType(); |
|
85 |
|
|
86 |
/** |
|
87 |
* Sets the data type |
|
88 |
* @param timeType |
|
89 |
*/ |
|
90 |
public void setDataType(int dataType); |
|
91 |
|
|
92 |
/** |
|
93 |
* Adds a new time value in the array. The parameter should be a date. |
|
94 |
* @param value |
|
83 | 95 |
* @throws ParseException |
84 | 96 |
*/ |
85 |
public void addDate(String dateStr) throws ParseException;
|
|
97 |
public void addValue(String value) throws ParseException;
|
|
86 | 98 |
|
87 | 99 |
/** |
100 |
* Adds a new time value in the array. The parameter should be a time instant. |
|
101 |
* @param value |
|
102 |
* @throws ParseException |
|
103 |
*/ |
|
104 |
public void addValue(double value); |
|
105 |
|
|
106 |
/** |
|
88 | 107 |
* Gets a string which represents a time information for that position. |
89 | 108 |
* Each position is or a single value or a part of a interval. |
90 | 109 |
* @param pos |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/DefaultTRasterStore.java | ||
---|---|---|
67 | 67 |
private ArrayList<RasterDataStore> list = new ArrayList<RasterDataStore>(); |
68 | 68 |
//Controla el store seleccionado |
69 | 69 |
private int selectedStore = 0; |
70 |
private String serialName = null; |
|
71 |
private String serialDescription = null; |
|
72 | 70 |
|
73 | 71 |
/** |
74 | 72 |
* Constructor. |
75 | 73 |
*/ |
76 | 74 |
public DefaultTRasterStore(RasterDataStore dataStore) throws TimeException { |
77 | 75 |
list.add(dataStore); |
78 |
SerialInfo sInfo; |
|
79 | 76 |
try { |
80 |
sInfo = dataStore.getSerialInfo(); |
|
81 |
serialName = sInfo.getName(); |
|
82 |
serialDescription = sInfo.getDescription(); |
|
77 |
dataStore.getSerialInfo(); |
|
83 | 78 |
} catch (RmfSerializerException e) { |
84 | 79 |
throw new TimeException(e.getMessage(), e); |
85 | 80 |
} |
... | ... | |
106 | 101 |
//Busca la serie del mismo nombre q la de este TRasterStore |
107 | 102 |
for (int j = 0; j < sInfo.getNumberOfSerials(); j++) { |
108 | 103 |
tInfo = sInfo.getSerial(j); |
109 |
if(tInfo.getSerialName().compareTo(serialName) == 0)
|
|
104 |
if(tInfo.getSerialName().compareTo(getSerialName()) == 0)
|
|
110 | 105 |
break; |
111 | 106 |
tInfo = null; |
112 | 107 |
} |
... | ... | |
713 | 708 |
* @see org.gvsig.fmap.dal.coverage.store.TRasterStore#getSerialName() |
714 | 709 |
*/ |
715 | 710 |
public String getSerialName() { |
716 |
return serialName; |
|
711 |
if(list.size() > 0) |
|
712 |
try { |
|
713 |
return list.get(0).getSerialInfo().getName(); |
|
714 |
} catch (RmfSerializerException e) { |
|
715 |
//La serie ya se ha cargado al principio con lo q no deber?a darse |
|
716 |
} |
|
717 |
return null; |
|
717 | 718 |
} |
718 | 719 |
|
719 | 720 |
/* |
... | ... | |
721 | 722 |
* @see org.gvsig.fmap.dal.coverage.store.TRasterStore#getSerialDescription() |
722 | 723 |
*/ |
723 | 724 |
public String getSerialDescription() { |
724 |
return serialDescription; |
|
725 |
if(list.size() > 0) |
|
726 |
try { |
|
727 |
return list.get(0).getSerialInfo().getDescription(); |
|
728 |
} catch (RmfSerializerException e) { |
|
729 |
//La serie ya se ha cargado al principio con lo q no deber?a darse |
|
730 |
} |
|
731 |
return null; |
|
725 | 732 |
} |
726 | 733 |
|
727 | 734 |
/* |
728 | 735 |
* (non-Javadoc) |
729 |
* @see org.gvsig.fmap.dal.coverage.store.TRasterStore#setSerialName(java.lang.String)
|
|
736 |
* @see org.gvsig.fmap.dal.coverage.store.TRasterStore#selectSerial(java.lang.String)
|
|
730 | 737 |
*/ |
731 |
public void setSerialName(String serialName) { |
|
732 |
this.serialName = serialName; |
|
738 |
public void selectSerial(String serialName) { |
|
739 |
for (int i = 0; i < list.size(); i++) { |
|
740 |
SerialInfo sInfo; |
|
741 |
try { |
|
742 |
sInfo = list.get(i).getSerialInfo(); |
|
743 |
sInfo.selectSerial(serialName); |
|
744 |
} catch (RmfSerializerException e) { |
|
745 |
//La serie ya se ha cargado al principio con lo q no deber?a darse |
|
746 |
} |
|
747 |
} |
|
733 | 748 |
} |
734 | 749 |
|
735 | 750 |
/* |
... | ... | |
737 | 752 |
* @see org.gvsig.fmap.dal.coverage.store.TRasterStore#setSerialDescription(java.lang.String) |
738 | 753 |
*/ |
739 | 754 |
public void setSerialDescription(String serialDescription) { |
740 |
this.serialDescription = serialDescription; |
|
755 |
for (int i = 0; i < list.size(); i++) { |
|
756 |
SerialInfo sInfo; |
|
757 |
try { |
|
758 |
sInfo = list.get(i).getSerialInfo(); |
|
759 |
sInfo.setDescription(serialDescription); |
|
760 |
} catch (RmfSerializerException e) { |
|
761 |
//La serie ya se ha cargado al principio con lo q no deber?a darse |
|
762 |
} |
|
763 |
} |
|
741 | 764 |
} |
765 |
|
|
766 |
/* |
|
767 |
* (non-Javadoc) |
|
768 |
* @see org.gvsig.fmap.dal.coverage.store.TRasterStore#setSerialName(java.lang.String) |
|
769 |
*/ |
|
770 |
public void setSerialName(String serialName) { |
|
771 |
for (int i = 0; i < list.size(); i++) { |
|
772 |
SerialInfo sInfo; |
|
773 |
try { |
|
774 |
sInfo = list.get(i).getSerialInfo(); |
|
775 |
sInfo.setName(serialName); |
|
776 |
} catch (RmfSerializerException e) { |
|
777 |
//La serie ya se ha cargado al principio con lo q no deber?a darse |
|
778 |
} |
|
779 |
} |
|
780 |
} |
|
742 | 781 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/serializer/SerialRmfSerializer.java | ||
---|---|---|
124 | 124 |
} |
125 | 125 |
try { |
126 | 126 |
if(d != null) |
127 |
tInfo.addDate(d); |
|
127 |
try { |
|
128 |
Double value = new Double(d); |
|
129 |
tInfo.addValue(value.doubleValue()); |
|
130 |
} catch (NumberFormatException e) { |
|
131 |
tInfo.addValue(d); |
|
132 |
} |
|
128 | 133 |
} catch (ParseException e) { |
129 | 134 |
} |
130 | 135 |
} while (d != null); |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/AbstractRasterDataStore.java | ||
---|---|---|
473 | 473 |
if(serialInfo == null) { |
474 | 474 |
serialInfo = new DataStoreSerialInfo(); |
475 | 475 |
loadSerialInfoFromRmf(serialInfo); |
476 |
DataStoreSerialInfo si = (DataStoreSerialInfo)serialInfo; |
|
477 |
if(si.getNumberOfSerials() > 0) { |
|
478 |
si.setName(si.getSerial(0).getSerialName()); |
|
479 |
si.setDescription(si.getSerial(0).getDescription()); |
|
480 |
} |
|
476 |
//Seleccionamos la primera serie por defecto. El usuario seleccionar? otra si la necesita |
|
477 |
serialInfo.selectSerial(0); |
|
481 | 478 |
} |
482 | 479 |
return serialInfo; |
483 | 480 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/properties/DataStoreSerialInfo.java | ||
---|---|---|
24 | 24 |
import java.text.ParseException; |
25 | 25 |
import java.util.ArrayList; |
26 | 26 |
|
27 |
import org.gvsig.fmap.dal.coverage.datastruct.TimeInfo; |
|
27 | 28 |
import org.gvsig.fmap.dal.coverage.store.props.SerialInfo; |
28 | 29 |
import org.gvsig.raster.impl.datastruct.DefaultTimeInfo; |
29 | 30 |
/** |
... | ... | |
33 | 34 |
*/ |
34 | 35 |
public class DataStoreSerialInfo implements SerialInfo { |
35 | 36 |
private ArrayList<DefaultTimeInfo> serial = new ArrayList<DefaultTimeInfo>(); |
36 |
private String description = null; |
|
37 |
private String name = null; |
|
37 |
private String description = null;
|
|
38 |
private String name = null;
|
|
38 | 39 |
|
39 | 40 |
/** |
40 | 41 |
* Constructor vacio. |
... | ... | |
44 | 45 |
|
45 | 46 |
/* |
46 | 47 |
* (non-Javadoc) |
48 |
* @see org.gvsig.fmap.dal.coverage.store.props.SerialInfo#selectSerial(java.lang.String) |
|
49 |
*/ |
|
50 |
public void selectSerial(String name) { |
|
51 |
for (int i = 0; i < serial.size(); i++) { |
|
52 |
if(serial.get(i).getSerialName().compareTo(name) == 0) { |
|
53 |
this.name = serial.get(i).getSerialName(); |
|
54 |
this.description = serial.get(i).getDescription(); |
|
55 |
} |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
/* |
|
60 |
* (non-Javadoc) |
|
61 |
* @see org.gvsig.fmap.dal.coverage.store.props.SerialInfo#selectSerial(int) |
|
62 |
*/ |
|
63 |
public void selectSerial(int pos) { |
|
64 |
if (pos >= 0 && pos < serial.size()) { |
|
65 |
this.name = serial.get(pos).getSerialName(); |
|
66 |
this.description = serial.get(pos).getDescription(); |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
47 | 72 |
* @see org.gvsig.fmap.dal.coverage.store.props.SerialInfo#getNumberOfSerials() |
48 | 73 |
*/ |
49 | 74 |
public int getNumberOfSerials() { |
... | ... | |
127 | 152 |
public void createNewTimeInterval(String dateA, String dateB) throws ParseException { |
128 | 153 |
DefaultTimeInfo tInfo = new DefaultTimeInfo(); |
129 | 154 |
tInfo.setTimeType(DefaultTimeInfo.RANGES); |
130 |
tInfo.addDate(dateA); |
|
131 |
tInfo.addDate(dateB); |
|
155 |
tInfo.setDataType(TimeInfo.DATE); |
|
156 |
tInfo.addValue(dateA); |
|
157 |
tInfo.addValue(dateB); |
|
132 | 158 |
tInfo.setDescription(description); |
133 | 159 |
tInfo.setSerialName(name); |
134 | 160 |
serial.add(tInfo); |
... | ... | |
141 | 167 |
public void createNewTimeValue(String value) throws ParseException { |
142 | 168 |
DefaultTimeInfo tInfo = new DefaultTimeInfo(); |
143 | 169 |
tInfo.setTimeType(DefaultTimeInfo.SINGLE_VALUES); |
144 |
tInfo.addDate(value); |
|
170 |
tInfo.setDataType(TimeInfo.DATE); |
|
171 |
tInfo.addValue(value); |
|
145 | 172 |
tInfo.setDescription(description); |
146 | 173 |
tInfo.setSerialName(name); |
147 | 174 |
serial.add(tInfo); |
148 | 175 |
} |
176 |
|
|
177 |
/* |
|
178 |
* (non-Javadoc) |
|
179 |
* @see org.gvsig.fmap.dal.coverage.store.props.SerialInfo#createNewTimeInterval(double, double) |
|
180 |
*/ |
|
181 |
public void createNewTimeInterval(double a, double b) throws ParseException { |
|
182 |
DefaultTimeInfo tInfo = new DefaultTimeInfo(); |
|
183 |
tInfo.setTimeType(DefaultTimeInfo.RANGES); |
|
184 |
tInfo.setDataType(TimeInfo.NUMERIC); |
|
185 |
tInfo.addValue(a); |
|
186 |
tInfo.addValue(b); |
|
187 |
tInfo.setDescription(description); |
|
188 |
tInfo.setSerialName(name); |
|
189 |
serial.add(tInfo); |
|
190 |
} |
|
191 |
|
|
192 |
/* |
|
193 |
* (non-Javadoc) |
|
194 |
* @see org.gvsig.fmap.dal.coverage.store.props.SerialInfo#createNewTimeValue(double) |
|
195 |
*/ |
|
196 |
public void createNewTimeValue(double value) throws ParseException { |
|
197 |
DefaultTimeInfo tInfo = new DefaultTimeInfo(); |
|
198 |
tInfo.setTimeType(DefaultTimeInfo.SINGLE_VALUES); |
|
199 |
tInfo.setDataType(TimeInfo.NUMERIC); |
|
200 |
tInfo.addValue(value); |
|
201 |
tInfo.setDescription(description); |
|
202 |
tInfo.setSerialName(name); |
|
203 |
serial.add(tInfo); |
|
204 |
} |
|
149 | 205 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/datastruct/DefaultTimeInfo.java | ||
---|---|---|
36 | 36 |
public static final int SINGLE_VALUES = 0; |
37 | 37 |
public static final int RANGES = 1; |
38 | 38 |
|
39 |
private ArrayList<Date> time = new ArrayList<Date>(); |
|
39 |
private ArrayList<Date> timeDate = new ArrayList<Date>(); |
|
40 |
private ArrayList<Double> timeNumeric = new ArrayList<Double>(); |
|
41 |
|
|
40 | 42 |
private int timeType = SINGLE_VALUES; |
43 |
private int dataType = DATE; |
|
41 | 44 |
private String timeFormat = null; |
42 | 45 |
private String serialName = null; |
43 | 46 |
private String description = null; |
... | ... | |
50 | 53 |
this.timeFormat = timeFormat; |
51 | 54 |
} |
52 | 55 |
|
53 |
public void load(String[] t, int type) throws ParseException { |
|
54 |
this.timeType = type; |
|
55 |
for (int i = 0; i < t.length; i++) |
|
56 |
addDate(t[i]); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Gets the serial name |
|
61 |
* @return |
|
56 |
/* |
|
57 |
* (non-Javadoc) |
|
58 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#getSerialName() |
|
62 | 59 |
*/ |
63 | 60 |
public String getSerialName() { |
64 | 61 |
return serialName; |
65 | 62 |
} |
66 | 63 |
|
67 |
/**
|
|
68 |
* Sets the serial name
|
|
69 |
* @param serialName
|
|
64 |
/* |
|
65 |
* (non-Javadoc)
|
|
66 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#setSerialName(java.lang.String)
|
|
70 | 67 |
*/ |
71 | 68 |
public void setSerialName(String serialName) { |
72 | 69 |
this.serialName = serialName; |
73 | 70 |
} |
74 | 71 |
|
75 |
/**
|
|
76 |
* Gets the list of dates
|
|
77 |
* @return
|
|
72 |
/* |
|
73 |
* (non-Javadoc)
|
|
74 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#getTime()
|
|
78 | 75 |
*/ |
79 |
public ArrayList<Date> getTime() {
|
|
80 |
return time;
|
|
76 |
public ArrayList<?> getTime() {
|
|
77 |
return dataType == DATE ? timeDate : timeNumeric ;
|
|
81 | 78 |
} |
82 | 79 |
|
83 |
/**
|
|
84 |
* Sets the list of dates
|
|
85 |
* @return
|
|
80 |
/* |
|
81 |
* (non-Javadoc)
|
|
82 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#setTime(java.util.ArrayList)
|
|
86 | 83 |
*/ |
87 |
public void setTime(ArrayList<Date> time) { |
|
88 |
this.time = time; |
|
84 |
@SuppressWarnings("unchecked") |
|
85 |
public void setTime(ArrayList<?> time) { |
|
86 |
if(dataType == DATE) |
|
87 |
timeDate = (ArrayList<Date>)time; |
|
88 |
else |
|
89 |
timeNumeric = (ArrayList<Double>)time; |
|
89 | 90 |
} |
90 | 91 |
|
91 |
/**
|
|
92 |
* Gets the time type
|
|
93 |
* @return
|
|
92 |
/* |
|
93 |
* (non-Javadoc)
|
|
94 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#getTimeType()
|
|
94 | 95 |
*/ |
95 | 96 |
public int getTimeType() { |
96 | 97 |
return timeType; |
97 | 98 |
} |
98 | 99 |
|
99 |
/**
|
|
100 |
* Sets the time type
|
|
101 |
* @param timeType
|
|
100 |
/* |
|
101 |
* (non-Javadoc)
|
|
102 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#setTimeType(int)
|
|
102 | 103 |
*/ |
103 | 104 |
public void setTimeType(int timeType) { |
104 | 105 |
this.timeType = timeType; |
105 | 106 |
} |
106 | 107 |
|
107 |
/**
|
|
108 |
* Sets the time type
|
|
109 |
* @param timeType
|
|
108 |
/* |
|
109 |
* (non-Javadoc)
|
|
110 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#getDataType()
|
|
110 | 111 |
*/ |
112 |
public int getDataType() { |
|
113 |
return dataType; |
|
114 |
} |
|
115 |
|
|
116 |
/* |
|
117 |
* (non-Javadoc) |
|
118 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#setDataType(int) |
|
119 |
*/ |
|
120 |
public void setDataType(int dataType) { |
|
121 |
this.dataType = dataType; |
|
122 |
} |
|
123 |
|
|
124 |
/* |
|
125 |
* (non-Javadoc) |
|
126 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#setTimeType(java.lang.String) |
|
127 |
*/ |
|
111 | 128 |
public void setTimeType(String timeType) { |
112 | 129 |
if(timeType.compareTo("Single values") == 0) |
113 | 130 |
this.timeType = 0; |
... | ... | |
115 | 132 |
this.timeType = 1; |
116 | 133 |
} |
117 | 134 |
|
118 |
/** |
|
119 |
* Adds a new date in the array |
|
120 |
* @param dateStr |
|
121 |
* @throws ParseException |
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#addDate(java.lang.String) |
|
122 | 138 |
*/ |
123 |
public void addDate(String dateStr) throws ParseException {
|
|
139 |
public void addValue(String value) throws ParseException {
|
|
124 | 140 |
SimpleDateFormat formatter = new SimpleDateFormat(timeFormat); |
125 | 141 |
Date date = null; |
126 | 142 |
try { |
127 |
date = formatter.parse(dateStr);
|
|
143 |
date = formatter.parse(value);
|
|
128 | 144 |
} catch (ParseException e) { |
129 |
date = formatter.parse(dateStr + "-00:00:00");
|
|
145 |
date = formatter.parse(value + "-00:00:00");
|
|
130 | 146 |
} |
131 | 147 |
|
132 |
this.time.add(date); |
|
148 |
this.timeDate.add(date);
|
|
133 | 149 |
} |
134 | 150 |
|
135 |
/** |
|
136 |
* Gets a string which represents a time information for that position. |
|
137 |
* Each position is or a single value or a part of a interval. |
|
138 |
* @param pos |
|
139 |
* @return |
|
151 |
/* |
|
152 |
* (non-Javadoc) |
|
153 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#addValue(double) |
|
140 | 154 |
*/ |
155 |
public void addValue(double value) { |
|
156 |
this.timeNumeric.add(new Double(value)); |
|
157 |
} |
|
158 |
|
|
159 |
/* |
|
160 |
* (non-Javadoc) |
|
161 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#getTimeInfo(int) |
|
162 |
*/ |
|
141 | 163 |
public String getTimeInfo(int pos) { |
142 |
SimpleDateFormat formatter = new SimpleDateFormat(timeFormat); |
|
143 |
return formatter.format(time.get(pos)); |
|
164 |
if(dataType == DATE) { |
|
165 |
SimpleDateFormat formatter = new SimpleDateFormat(timeFormat); |
|
166 |
return formatter.format(timeDate.get(pos)); |
|
167 |
} |
|
168 |
if(dataType == NUMERIC) { |
|
169 |
return timeNumeric.get(pos).doubleValue() + ""; |
|
170 |
} |
|
171 |
return null; |
|
144 | 172 |
} |
145 | 173 |
|
146 |
/**
|
|
147 |
* Gets the description
|
|
148 |
* @param description
|
|
174 |
/* |
|
175 |
* (non-Javadoc)
|
|
176 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#getDescription()
|
|
149 | 177 |
*/ |
150 | 178 |
public String getDescription() { |
151 | 179 |
return description; |
152 | 180 |
} |
153 | 181 |
|
154 |
/**
|
|
155 |
* Sets the description
|
|
156 |
* @return
|
|
182 |
/* |
|
183 |
* (non-Javadoc)
|
|
184 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#setDescription(java.lang.String)
|
|
157 | 185 |
*/ |
158 | 186 |
public void setDescription(String description) { |
159 | 187 |
this.description = description; |
160 | 188 |
} |
161 | 189 |
|
190 |
/* |
|
191 |
* (non-Javadoc) |
|
192 |
* @see org.gvsig.fmap.dal.coverage.datastruct.TimeInfo#isInRange(org.gvsig.fmap.dal.coverage.datastruct.TimeInfo) |
|
193 |
*/ |
|
194 |
public boolean isInRange(TimeInfo tInfo) { |
|
195 |
if(dataType == DATE) { |
|
196 |
return isInRangeDateType(tInfo); |
|
197 |
} |
|
198 |
if(dataType == NUMERIC) { |
|
199 |
return isInRangeNumericType(tInfo); |
|
200 |
} |
|
201 |
return false; |
|
202 |
} |
|
203 |
|
|
162 | 204 |
/** |
163 | 205 |
* Returns true if the range selected in the parameters is |
164 | 206 |
* inside the current. |
165 | 207 |
* @param tInfo |
166 | 208 |
* @return |
167 | 209 |
*/ |
168 |
public boolean isInRange(TimeInfo tInfo) { |
|
169 |
ArrayList<Date> t1 = tInfo.getTime(); |
|
170 |
ArrayList<Date> t2 = getTime(); |
|
210 |
@SuppressWarnings("unchecked") |
|
211 |
private boolean isInRangeDateType(TimeInfo tInfo) { |
|
212 |
ArrayList<Date> t1 = (ArrayList<Date>)tInfo.getTime(); |
|
213 |
ArrayList<Date> t2 = (ArrayList<Date>)getTime(); |
|
171 | 214 |
if(t1.size() == 1 && t2.size() == 1) { |
172 | 215 |
long dif = t1.get(0).getTime() - t2.get(0).getTime(); |
173 | 216 |
if(dif == 0) |
... | ... | |
196 | 239 |
} |
197 | 240 |
return false; |
198 | 241 |
} |
242 |
|
|
243 |
/** |
|
244 |
* Returns true if the range selected in the parameters is |
|
245 |
* inside the current. |
|
246 |
* @param tInfo |
|
247 |
* @return |
|
248 |
*/ |
|
249 |
@SuppressWarnings("unchecked") |
|
250 |
private boolean isInRangeNumericType(TimeInfo tInfo) { |
|
251 |
ArrayList<Double> t1 = (ArrayList<Double>)tInfo.getTime(); |
|
252 |
ArrayList<Double> t2 = (ArrayList<Double>)getTime(); |
|
253 |
if(t1.size() == 1 && t2.size() == 1) { |
|
254 |
double dif = t1.get(0).doubleValue() - t2.get(0).doubleValue(); |
|
255 |
if(dif == 0) |
|
256 |
return true; |
|
257 |
} |
|
258 |
|
|
259 |
if(t1.size() == 1 && t2.size() > 1) { |
|
260 |
double dif1 = t1.get(0).doubleValue() - t2.get(0).doubleValue(); |
|
261 |
double dif2 = t1.get(0).doubleValue() - t2.get(t2.size() - 1).doubleValue(); |
|
262 |
if(dif1 > 0 && dif2 < 0) |
|
263 |
return true; |
|
264 |
} |
|
265 |
|
|
266 |
if(t1.size() > 1 && t2.size() == 1) { |
|
267 |
double dif1 = t1.get(0).doubleValue() - t2.get(0).doubleValue(); |
|
268 |
double dif2 = t1.get(t1.size() - 1).doubleValue() - t2.get(0).doubleValue(); |
|
269 |
if(dif1 == 0 && dif2 == 0) |
|
270 |
return true; |
|
271 |
} |
|
272 |
|
|
273 |
if(t1.size() > 1 && t2.size() > 1) { |
|
274 |
double dif1 = t1.get(0).doubleValue() - t2.get(0).doubleValue(); |
|
275 |
double dif2 = t1.get(t1.size() - 1).doubleValue() - t2.get(t2.size() - 1).doubleValue(); |
|
276 |
if(dif1 >= 0 && dif2 <= 0) |
|
277 |
return true; |
|
278 |
} |
|
279 |
return false; |
|
280 |
} |
|
199 | 281 |
} |
Also available in: Unified diff