Revision 41745 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.shape/src/main/java/org/gvsig/exportto/swing/prov/shape/ExporttoShapeService.java
ExporttoShapeService.java | ||
---|---|---|
85 | 85 |
|
86 | 86 |
private static Logger logger = LoggerFactory.getLogger(ExporttoShapeService.class); |
87 | 87 |
|
88 |
public static final int MAX_FIELD_NAME_LENGTH = 11;
|
|
88 |
public static final int MAX_FIELD_NAME_LENGTH = 10;
|
|
89 | 89 |
|
90 | 90 |
private File theShapeFile; |
91 | 91 |
private IProjection projection; |
... | ... | |
145 | 145 |
* Composes a new name with start and end of old name and an index |
146 | 146 |
* THISISAVERYLONGNAME => THISI_AME_1, THISI_AME_2 ... THISI_AME_9 |
147 | 147 |
*/ |
148 |
/* |
|
148 | 149 |
String pref = name.substring(0, 6) + "_" + name.substring(len - 2) + "_"; |
149 | 150 |
String resp = null; |
150 | 151 |
for (int i=0; i<10; i++) { |
... | ... | |
153 | 154 |
return resp; |
154 | 155 |
} |
155 | 156 |
} |
157 |
*/ |
|
156 | 158 |
/* |
157 | 159 |
* Very strange to get here... |
158 | 160 |
* THISISAVERYLONGNAME => THISISA_1, THISISA_2 ... THISISA_999 |
159 | 161 |
*/ |
162 |
/* |
|
160 | 163 |
pref = name.substring(0, 7) + "_"; |
161 | 164 |
for (int i=0; i<1000; i++) { |
162 | 165 |
resp = pref + i; |
... | ... | |
164 | 167 |
return resp; |
165 | 168 |
} |
166 | 169 |
} |
170 |
*/ |
|
167 | 171 |
/* |
172 |
* GDAL field name truncation method (extended from 100 to 255) |
|
173 |
* THISISAVERYLONGNAME => THISISAVER, THISISAV_1 ... THISISAV_9, |
|
174 |
* THISISAV10 ... THISISAV99, THISISA100 ... THISISA255 |
|
175 |
* (255 = max number of fields in a SHP) |
|
176 |
*/ |
|
177 |
String resp = null; |
|
178 |
for (int i=0; i<255; i++) { |
|
179 |
if (i==0) |
|
180 |
resp = name.substring(0, 10); |
|
181 |
else if (i<=9) |
|
182 |
resp = name.substring(0, 8) + "_" + i; |
|
183 |
else if (i<=99) |
|
184 |
resp = name.substring(0, 8) + i; |
|
185 |
else |
|
186 |
resp = name.substring(0, 7) + i; |
|
187 |
if (!values.contains(resp)) |
|
188 |
return resp; |
|
189 |
} |
|
190 |
/* |
|
168 | 191 |
* Should not get here |
169 | 192 |
*/ |
170 | 193 |
return name.substring(0, 4) + "_" + (System.currentTimeMillis() % 1000000); |
Also available in: Unified diff