Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / utils / Export.java @ 27564

History | View | Annotate | Download (4.2 KB)

1 27564 vsanjaime
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 Prodevelop S.L  vsanjaime   programador
26
 */
27
28
package org.gvsig.geocoding.utils;
29
30
import org.gvsig.geocoding.extension.GeocoController;
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33
34
/**
35
 * This class generates a Layer from feature store
36
 *
37
 * @author Jorge Gaspar Sanz Salinas (jsanz@prodevelop.es)
38
 * @author Vicente Sanjaime Calvet (vsanjaime@prodevelop.es)
39
 *
40
 */
41
42
public class Export extends Thread {
43
44
        private Logger log = LoggerFactory.getLogger(Export.class);
45
        GeocoController control = null;
46
47
48
49
        /**
50
         * Constructor with list of results
51
         *
52
         * @param file
53
         */
54
        public Export(GeocoController control) {
55
                super();
56
                this.control = control;
57
58
        }
59
60
        /**
61
         * Run
62
         */
63
        public void run() {
64
65
//                boolean compose = false;
66
//                boolean cross = true;
67
//
68
//        // address fields
69
//                Set<GeocodingResult> result = control.getGmodel().getAllResults().get(0);
70
//                Address address = null;
71
//                for (GeocodingResult res : result) {
72
//                        address = res.getAddress();
73
//                        break;
74
//                }
75
//                Literal literal = address.getMainLiteral();
76
//                int cant = literal.size();
77
//                String[] fields = new String[cant];
78
//                int i = 0;
79
//                for (Object obj : literal) {
80
//                        AddressComponent aComp= (AddressComponent)obj;
81
//                        fields[i]= aComp.getKeyElement();
82
//                        i++;
83
//                }
84
//                if(address instanceof ComposeAddress){
85
//                        compose = true;
86
//                        ComposeAddress caddress = (ComposeAddress)address;
87
//                        List<Literal> inter = caddress.getIntersectionLiteral();
88
//                        if(inter.size() == 2){
89
//                                cross = false;
90
//                        }
91
//                }
92
//
93
//                // new store
94
//                DataManager manager = DALLocator.getDataManager();
95
//                try {
96
//                DataServerExplorerParameters eparams = manager
97
//                                .createServerExplorerParameters("FilesystemExplorer");
98
//                eparams.setDynValue("initialpath","c:/temp");
99
//                DataServerExplorer serverExplorer = manager.createServerExplorer(eparams);
100
//
101
//                DataParameters sparams = serverExplorer.getAddParameters("Shape");
102
//                sparams.setDynValue("fileName","geocode.shp");
103
//
104
//                EditableFeatureType featureType = (EditableFeatureType) sparams.getDynValue("defaultFeatureType");
105
//
106
//                // no compose address
107
//                if(!compose){
108
//                        for (String field : fields) {
109
//                                featureType.add(field, DefaultFeatureAttributeDescriptor.TYPE_STRING,50);
110
//                        }
111
//
112
//                }
113
//                // compose address
114
//                else{
115
//                        for (String field : fields) {
116
//                                featureType.add(field+"_1", FeatureAttributeDescriptor.TYPE_STRING,50);
117
//                        }
118
//                        for (String field : fields) {
119
//                                featureType.add(field+"_2", FeatureAttributeDescriptor.TYPE_STRING,50);
120
//                        }
121
//
122
//
123
//                        // compose between address
124
//                        if(!cross){
125
//                                for (String field : fields) {
126
//                                        featureType.add(field+"_3", FeatureAttributeDescriptor.TYPE_STRING,50);
127
//                                }
128
//
129
//                        }
130
//
131
//
132
//                }
133
//                featureType.add("GEOM", FeatureAttributeDescriptor.TYPE_GEOMETRY);
134
//
135
//                serverExplorer.add(sparams, true);
136
137
138
139
//                // create layer
140
//                LayerFactory factory = LayerFactory.getInstance();
141
//                String layerName = "GEOCODE";
142
//                try {
143
//                        FLayer lyr = factory.createLayer(layerName, params);
144
//                } catch (LoadLayerException e) {
145
//                        // TODO Auto-generated catch block
146
//                        e.printStackTrace();
147
//                }
148
//                // add layer TOC
149
150
        }
151
152
153
154
}