svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / raster / impl / DefaultRasterKernel.java @ 47248
History | View | Annotate | Download (2.7 KB)
1 | 43803 | fdiaz | /* 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 | package org.gvsig.fmap.dal.raster.impl; |
||
24 | |||
25 | 43876 | jjdelcerro | import org.gvsig.fmap.dal.raster.RasterKernel; |
26 | 43803 | fdiaz | import org.gvsig.raster.lib.buffer.api.Buffer; |
27 | |||
28 | /**
|
||
29 | * Implements RasterKernel
|
||
30 | * @author dmartinezizquierdo
|
||
31 | *
|
||
32 | */
|
||
33 | public class DefaultRasterKernel implements RasterKernel{ |
||
34 | |||
35 | Buffer buffer;
|
||
36 | int row;
|
||
37 | int column;
|
||
38 | |||
39 | /**
|
||
40 | * Creates the raster kernel with the raster buffer
|
||
41 | * @param buffer
|
||
42 | */
|
||
43 | public DefaultRasterKernel(Buffer buffer){ |
||
44 | this.buffer=buffer;
|
||
45 | } |
||
46 | |||
47 | /**
|
||
48 | * Row and Column from the raster
|
||
49 | * @param row
|
||
50 | * @param column
|
||
51 | */
|
||
52 | public void set(int row,int column){ |
||
53 | this.row=row;
|
||
54 | this.column=column;
|
||
55 | } |
||
56 | |||
57 | @Override
|
||
58 | public int getBandCount() { |
||
59 | return buffer.getBandCount();
|
||
60 | } |
||
61 | |||
62 | @Override
|
||
63 | public int getRow() { |
||
64 | return row;
|
||
65 | } |
||
66 | |||
67 | @Override
|
||
68 | public int getColumn() { |
||
69 | return column;
|
||
70 | } |
||
71 | |||
72 | @Override
|
||
73 | public Object[] getValue() { |
||
74 | Object[] value=new Object[getBandCount()]; |
||
75 | for (int i=0; i<getBandCount(); i++){ |
||
76 | value[i]=buffer.getBand(i).get(row, column); |
||
77 | } |
||
78 | return value;
|
||
79 | } |
||
80 | |||
81 | @Override
|
||
82 | public Object[][][] getValues() { |
||
83 | int maxRows=buffer.getRows();
|
||
84 | int maxColumns=buffer.getColumns();
|
||
85 | Object[][][] value=new Object[3][3][getBandCount()]; |
||
86 | for (int i=-1; i<2;i++){ |
||
87 | for (int j=-1; j<2;j++){ |
||
88 | for (int b=0; b<getBandCount(); b++){ |
||
89 | Object obj = null; |
||
90 | if ( row+i>=0 && row+i<=maxRows && column+j>=0 && column+j<=maxColumns){ |
||
91 | obj = buffer.getBand(b).get(row+i, column+j); |
||
92 | } |
||
93 | value[1+i][1+j][b]=obj; |
||
94 | } |
||
95 | } |
||
96 | } |
||
97 | return value;
|
||
98 | } |
||
99 | |||
100 | } |