@@ -245,27 +245,6 @@ public int findID( double lat, double lon )
245
245
return res .getClosestNode ();
246
246
}
247
247
248
- @ Override
249
- public boolean loadExisting ()
250
- {
251
- if (initialized )
252
- throw new IllegalStateException ("Call loadExisting only once" );
253
-
254
- if (!dataAccess .loadExisting ())
255
- return false ;
256
-
257
- if (dataAccess .getHeader (0 ) != MAGIC_INT )
258
- throw new IllegalStateException ("incorrect location2id index version, expected:" + MAGIC_INT );
259
-
260
- if (dataAccess .getHeader (1 * 4 ) != calcChecksum ())
261
- throw new IllegalStateException ("location2id index was opened with incorrect graph" );
262
-
263
- setMinResolutionInMeter (dataAccess .getHeader (2 * 4 ));
264
- prepareAlgo ();
265
- initialized = true ;
266
- return true ;
267
- }
268
-
269
248
@ Override
270
249
public LocationIndex setResolution ( int minResolutionInMeter )
271
250
{
@@ -292,10 +271,32 @@ public LocationIndexTree create( long size )
292
271
throw new UnsupportedOperationException ("Not supported. Use prepareIndex instead." );
293
272
}
294
273
274
+ @ Override
275
+ public boolean loadExisting ()
276
+ {
277
+ if (initialized )
278
+ throw new IllegalStateException ("Call loadExisting only once" );
279
+
280
+ if (!dataAccess .loadExisting ())
281
+ return false ;
282
+
283
+ if (dataAccess .getHeader (0 ) != MAGIC_INT )
284
+ throw new IllegalStateException ("incorrect location2id index version, expected:" + MAGIC_INT );
285
+
286
+ if (dataAccess .getHeader (1 * 4 ) != calcChecksum ())
287
+ throw new IllegalStateException ("location2id index was opened with incorrect graph: "
288
+ + dataAccess .getHeader (1 * 4 ) + " vs. " + calcChecksum ());
289
+
290
+ setMinResolutionInMeter (dataAccess .getHeader (2 * 4 ));
291
+ prepareAlgo ();
292
+ initialized = true ;
293
+ return true ;
294
+ }
295
+
295
296
@ Override
296
297
public void flush ()
297
298
{
298
- dataAccess .setHeader (0 , MAGIC_INT );
299
+ dataAccess .setHeader (0 , MAGIC_INT );
299
300
dataAccess .setHeader (1 * 4 , calcChecksum ());
300
301
dataAccess .setHeader (2 * 4 , minResolutionInMeter );
301
302
@@ -331,6 +332,7 @@ public LocationIndex prepareIndex()
331
332
+ ", leafs:" + Helper .nf (inMem .leafs )
332
333
+ ", precision:" + minResolutionInMeter
333
334
+ ", depth:" + entries .length
335
+ + ", checksum:" + calcChecksum ()
334
336
+ ", entries:" + Arrays .toString (entries )
335
337
+ ", entriesPerLeaf:" + entriesPerLeaf );
336
338
0 commit comments