source: gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/ServerSideTests.java@ 23934

Last change on this file since 23934 was 23934, checked in by sjm84, 13 years ago

Extensive improvements to the ATLAS code

File size: 53.7 KB
Line 
1package org.greenstone.atlas.server;
2
3import java.awt.BorderLayout;
4import java.awt.GridLayout;
5import java.awt.event.ActionEvent;
6import java.awt.event.ActionListener;
7import java.io.BufferedReader;
8import java.io.BufferedWriter;
9import java.io.DataOutputStream;
10import java.io.FileReader;
11import java.io.FileWriter;
12import java.io.InputStreamReader;
13import java.net.HttpURLConnection;
14import java.net.URL;
15import java.sql.Connection;
16import java.sql.DriverManager;
17import java.sql.ResultSet;
18import java.sql.Statement;
19import java.util.ArrayList;
20import java.util.HashMap;
21import java.util.TreeMap;
22
23import javax.swing.ButtonGroup;
24import javax.swing.JButton;
25import javax.swing.JFrame;
26import javax.swing.JList;
27import javax.swing.JPanel;
28import javax.swing.JRadioButton;
29import javax.swing.JScrollPane;
30import javax.swing.ListModel;
31import javax.swing.event.ListSelectionEvent;
32import javax.swing.event.ListSelectionListener;
33
34import org.greenstone.atlas.client.Place;
35
36public class ServerSideTests
37{
38 String _currentLine = null;
39 ArrayList<String> _words = new ArrayList<String>();
40
41 /**
42 * @param args
43 */
44 public static void main(String[] args)
45 {
46 // GazetteerTrie trie = new
47 // GazetteerTrie("/home/sam/Desktop/Research/Greenstone3-gate-svn2/web/GPNMS/dataen.txt");
48 // PlacesToPoints();
49
50 ServerSideTests sst = new ServerSideTests();
51 sst.go();
52 }
53
54 public void go()
55 {
56 DatabaseFix();
57 //PlacesToPoints();
58 // ExperimentSetUp();
59 //PrecisionExperiment();
60 //GazetteerExperiment();
61 //GazetteerTest();
62 //ModPlaceNames();
63 //analyseResults();
64 }
65
66 public void analyseResults()
67 {
68 try
69 {
70 BufferedReader in = new BufferedReader(new FileReader("/home/sjm84/Desktop/deleteMe.txt"));
71
72 TreeMap<Double, ArrayList<Double[]>> scores = new TreeMap<Double, ArrayList<Double[]>>();
73
74 Double[] currentConfig = null;
75
76 String line = null;
77 boolean score = false;
78 while((line = in.readLine()) != null)
79 {
80 if(score)
81 {
82 String[] scanScores = line.split(" ");
83 Double averageScore = Double.parseDouble(scanScores[5]);
84
85 if(scores.containsKey(averageScore))
86 {
87 scores.get(averageScore).add(currentConfig);
88 }
89 else
90 {
91 ArrayList<Double[]> newList = new ArrayList<Double[]>();
92 newList.add(currentConfig);
93 scores.put(averageScore, newList);
94 }
95 }
96 else
97 {
98 String[] configValues = line.split(" ");
99 currentConfig = new Double[configValues.length];
100
101 for(int i = 0; i < configValues.length; i++)
102 {
103 currentConfig[i] = Double.parseDouble(configValues[i]);
104 }
105 }
106
107 score = !score;
108 }
109
110 BufferedWriter out = new BufferedWriter(new FileWriter("/home/sjm84/Desktop/SortedScores.txt"));
111
112 for(Double d : scores.keySet())
113 {
114 out.write(d + " -> ");
115 ArrayList<Double[]> current = scores.get(d);
116
117 for(Double[] da : current)
118 {
119 for(int i = 0; i < da.length; i++)
120 {
121 out.write(da[i] + " ");
122 }
123
124 out.write(" - ");
125 }
126 out.write("\n");
127 }
128
129 in.close();
130 out.close();
131 }
132 catch(Exception ex)
133 {
134 ex.printStackTrace();
135 }
136 }
137
138 public void ModPlaceNames()
139 {
140 try
141 {
142 BufferedReader in = new BufferedReader(new FileReader("/home/sjm84/Desktop/placenames.txt"));
143
144 ArrayList<String> words = new ArrayList<String>();
145
146 String line = null;
147 while((line = in.readLine()) != null)
148 {
149 String[] w = line.split(" ");
150 for(int i = 0; i < w.length; i++)
151 {
152 words.add(w[i]);
153 }
154 }
155
156 BufferedWriter out = new BufferedWriter(new FileWriter("/home/sjm84/Desktop/placenames.txt"));
157
158 for(int i = 0; i < words.size(); i++)
159 {
160 for(int j = 0; j < words.get(i).length(); j++)
161 {
162 if(words.get(i).charAt(j) > 127)
163 {
164 out.write(words.get(i) + "\n");
165 }
166 }
167 }
168 }
169 catch (Exception e)
170 {
171 e.printStackTrace();
172 }
173 }
174
175 public void GazetteerExperiment()
176 {
177 showMemoryUsage();
178 }
179
180 public interface ObjectFactory
181 {
182 public Object makeObject();
183 }
184
185 public long calculateMemoryUsage()
186 {
187 ObjectFactory factory = new ObjectFactory()
188 {
189 public Object makeObject()
190 {
191 return new GazetteerTrieType5("/home/sam/Desktop/Research/Greenstone3-gate-svn2/web/GPNMS/dataen.txt");
192 }
193 };
194
195 Object handle = factory.makeObject();
196 long mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
197 long mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
198 handle = null;
199 System.gc();
200 System.gc();
201 System.gc();
202 System.gc();
203 System.gc();
204 System.gc();
205 System.gc();
206 System.gc();
207 System.gc();
208 System.gc();
209 System.gc();
210 System.gc();
211 System.gc();
212 System.gc();
213 System.gc();
214 System.gc();
215 mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
216 handle = factory.makeObject();
217 System.gc();
218 System.gc();
219 System.gc();
220 System.gc();
221 System.gc();
222 System.gc();
223 System.gc();
224 System.gc();
225 System.gc();
226 System.gc();
227 System.gc();
228 System.gc();
229 System.gc();
230 System.gc();
231 System.gc();
232 System.gc();
233 mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
234 return mem1 - mem0;
235 }
236
237 public void showMemoryUsage()
238 {
239
240 long mem = 0;
241 for(int i = 0;i < 10; i++)
242 {
243 mem += calculateMemoryUsage();
244 }
245 System.out.println("Object takes " + (int)(mem/10) + " bytes");
246 }
247
248 public void ExperimentSetUp()
249 {
250 final JFrame frame = new JFrame("Experiment setup program");
251 JList placeList = null;
252 final ButtonGroup alts = new ButtonGroup();
253 final ArrayList<JRadioButton> buttons = new ArrayList<JRadioButton>();
254 final JPanel buttonPanel = new JPanel();
255 buttonPanel.setLayout(new GridLayout(30, 3));
256 final HashMap<String, Place> choices = new HashMap<String, Place>();
257 final ArrayList<Place> possibleChoices = new ArrayList<Place>();
258 JButton enter = new JButton("GO");
259 String filename = "/research/sjm84/Msc/GNSDocs/ireland.html";// "/home/sam/Desktop/Research/GNSDocs/canada.html";//
260
261 try
262 {
263 PageScanner ps = new PageScanner("/research/sjm84/Msc/Downloads/");// new
264 // PageScanner("/home/sam/Desktop/Research/");//
265
266 BufferedReader file = new BufferedReader(new FileReader(filename));
267
268 ArrayList<ArrayList<String>> lines = new ArrayList<ArrayList<String>>();
269 String line = null;
270 while ((line = file.readLine()) != null)
271 {
272 lines.add(MarkupService.findWords(line));
273 }
274
275 ps.examineTextWithoutGate(lines);
276 final ArrayList<Place> filePlaces = ps.getPlaces();
277 ArrayList<Place> seenPlaces = new ArrayList<Place>();
278 for (Place p : filePlaces)
279 {
280 if (p.isDirectlyReferenced())
281 {
282 boolean found = false;
283 for (int i = 0; i < seenPlaces.size(); i++)
284 {
285 if (p.getName().equals(seenPlaces.get(i).getName()))
286 {
287 found = true;
288 break;
289 }
290 }
291 if (!found)
292 {
293 seenPlaces.add(p);
294 }
295 }
296 }
297
298 String[] items = new String[seenPlaces.size()];
299 for (int i = 0; i < seenPlaces.size(); i++)
300 {
301 items[i] = seenPlaces.get(i).getName();
302 choices.put(seenPlaces.get(i).getName(), null);
303 }
304
305 placeList = new JList(items);
306
307 placeList.addListSelectionListener(new ListSelectionListener()
308 {
309 int prevIndex = -1;
310
311 public void valueChanged(ListSelectionEvent e)
312 {
313 ListModel model = ((JList) (e.getSource())).getModel();
314 int index = ((JList) (e.getSource())).getSelectedIndex();
315 final String s = (String) (model.getElementAt(index));
316 if (index != prevIndex)
317 {
318 System.out.println("Value Changed!");
319 for (JRadioButton button : buttons)
320 {
321 buttonPanel.remove(button);
322 alts.remove(button);
323 }
324
325 buttons.clear();
326 possibleChoices.clear();
327
328 System.out.println("*Adding Button!");
329 JRadioButton noneButton = new JRadioButton("*None*");
330 alts.add(noneButton);
331 buttons.add(noneButton);
332 buttonPanel.add(noneButton);
333 noneButton.addActionListener(new ActionListener()
334 {
335 public void actionPerformed(ActionEvent e)
336 {
337 choices.put(s, null);
338 }
339 });
340
341 int count = 0;
342 for (Place p : filePlaces)
343 {
344 if (p.getName().equals(s))
345 {
346 System.out.println("Adding Button!");
347 possibleChoices.add(p);
348
349 JRadioButton button = new JRadioButton(p.getName() + ", " + p.getParentPlaceName());
350 alts.add(button);
351 buttons.add(button);
352 buttonPanel.add(button);
353 button.addActionListener(new RadioActionListener(count++, possibleChoices, choices));
354 }
355 }
356
357 buttonPanel.setSize(600, 150);
358 buttonPanel.validate();
359 frame.pack();
360 frame.validate();
361 }
362 prevIndex = ((JList) (e.getSource())).getSelectedIndex();
363 }
364 });
365
366 enter.addActionListener(new ButtonActionListener(choices));
367 }
368 catch (Exception ex)
369 {
370 ex.printStackTrace();
371 }
372
373 JScrollPane sp = new JScrollPane(placeList);
374 frame.setLayout(new BorderLayout());
375 sp.setSize(600, 150);
376 frame.add(sp, BorderLayout.WEST);
377 buttonPanel.setSize(600, 150);
378 frame.add(buttonPanel, BorderLayout.CENTER);
379 enter.setSize(600, 100);
380 frame.add(enter, BorderLayout.EAST);
381 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
382 frame.setSize(600, 400);
383 frame.setVisible(true);
384 }
385
386 class RadioActionListener implements ActionListener
387 {
388 int _index = -1;
389 ArrayList<Place> _possibleChoices = null;
390 HashMap<String, Place> _choices = null;
391
392 public RadioActionListener(int index, ArrayList<Place> possibleChoices, HashMap<String, Place> choices)
393 {
394 _index = index;
395 _possibleChoices = possibleChoices;
396 _choices = choices;
397 }
398
399 public void actionPerformed(ActionEvent e)
400 {
401 System.out.println("BUTTON CLICKED");
402 _choices.put(_possibleChoices.get(_index).getName(), _possibleChoices.get(_index));
403 }
404 }
405
406 class ButtonActionListener implements ActionListener
407 {
408 HashMap<String, Place> _choices = null;
409
410 public ButtonActionListener(HashMap<String, Place> choices)
411 {
412 _choices = choices;
413 }
414
415 public void actionPerformed(ActionEvent e)
416 {
417 System.out.println("GO CLICKED");
418 try
419 {
420 BufferedWriter out = new BufferedWriter(new FileWriter("/home/sjm84/Desktop/test.txt"));
421
422 for (String s : _choices.keySet())
423 {
424 System.out.println(s + " == " + _choices.get(s));
425 if (_choices.get(s) != null)
426 {
427 out.write("new Long(" + _choices.get(s).getId() + "), /* " + _choices.get(s).getName() + " */\n");
428 }
429 }
430 out.close();
431 }
432 catch (Exception exception)
433 {
434 exception.printStackTrace();
435 }
436 }
437 }
438
439 public void PrecisionExperiment()
440 {
441 ArrayList<ScanConfiguration> configs = new ArrayList<ScanConfiguration>();
442 HashMap<ScanConfiguration, ArrayList<int[]>> results = new HashMap<ScanConfiguration, ArrayList<int[]>>();
443
444 for (int i = 0; i < 6; i++)
445 {
446 for (int j = 0; j < 6; j++)
447 {
448 for (int k = 0; k < 6; k++)
449 {
450 for(int l = 0; l < 6; l++)
451 {
452 ScanConfiguration sc = new ScanConfiguration(0.2 * i, 0.2 * j, 0.2 * k, l);
453 //ScanConfiguration sc = new ScanConfiguration(0, 0.8, 0.0, 1);
454 configs.add(sc);
455 results.put(sc, new ArrayList<int[]>());
456
457 if(j == 0)
458 {
459 break;
460 }
461 }
462 }
463 }
464 }
465
466 try
467 {
468 PageScanner ps = new PageScanner("/research/sjm84/Msc/Downloads/");
469 //PageScanner ps = new PageScanner("/home/sam/Desktop/Research/");
470
471 String[] filenames = new String[] { "australia", "canada", "ireland", "southafrica", "washington" };
472 for (int i = 0; i < filenames.length; i++)
473 {
474 BufferedReader file = new BufferedReader(new FileReader("/research/sjm84/Msc/GNSDocs/" + filenames[i] + ".html"));
475 //BufferedReader file = new BufferedReader(new FileReader("/home/sam/Desktop/Research/GNSDocs/" + filenames[i] + ".html"));
476
477 StringBuilder text = new StringBuilder();
478 String line = null;
479 while ((line = file.readLine()) != null)
480 {
481 text.append(line);
482 }
483
484 ScanResultSet correctResults = getCorrectScanResultSet(i);
485 ArrayList<String> textPlaces = ps.getPlaceNames(text.toString());
486
487 int count = 0;
488 for (ScanConfiguration sc : configs)
489 {
490 count++;
491 System.out.println(sc + " " + count);
492 ps.setScoringParams(sc);
493 ps.examineArrayOfStrings(textPlaces);
494 ScanResultSet scanResult = new ScanResultSet(filenames[i], ps.getPlaces());
495 //correctResults.updateScores(ps.getPlaces());
496 int[] compareResults = correctResults.compareResults(scanResult);
497 if(compareResults == null)
498 {
499 System.out.println("NULL?!?");
500 }
501 else
502 {
503 results.get(sc).add(compareResults);
504 }
505 }
506 }
507
508 BufferedWriter out = new BufferedWriter(new FileWriter("/home/sjm84/Desktop/deleteMe.txt"));
509 //BufferedWriter out = new BufferedWriter(new FileWriter("/home/sam/Desktop/scanResults.txt"));
510
511 for (ScanConfiguration sc : results.keySet())
512 {
513 out.write(sc.toString() + "\n");
514 int correctCount = 0;
515 int totalCount = 0;
516 for (int[] i : results.get(sc))
517 {
518 out.write(((double)(i[0]))/((double)(i[1])) + " ");
519 correctCount += i[0];
520 totalCount += i[1];
521 }
522
523 out.write(((double)(correctCount)) / ((double)(totalCount)) + "\n");
524 }
525 out.close();
526 }
527 catch (Exception ex)
528 {
529 ex.printStackTrace();
530 }
531 }
532
533 public static void ListPopulate()
534 {
535 Statement database = null;
536
537 try
538 {
539 Class.forName("org.postgresql.Driver");
540 Connection c = DriverManager.getConnection("jdbc:postgresql://localhost/GS3MapDB", "sam", "password");
541
542 database = c.createStatement();
543
544 ResultSet places = database.executeQuery("SELECT placename, placetype FROM places WHERE population > -1");
545
546 BufferedWriter countryList = new BufferedWriter(new FileWriter("/research/sjm84/Msc/Downloads/CountryList.lst"));
547 BufferedWriter cityList = new BufferedWriter(new FileWriter("/research/sjm84/Msc/Downloads/CityList.lst"));
548
549 while (places.next())
550 {
551 String pn = places.getString("placename");
552 String pt = places.getString("placetype");
553
554 if (pt.equals("country"))
555 {
556 countryList.write(pn + "\n");
557 }
558 else
559 {
560 cityList.write(pn + "\n");
561 }
562 }
563 places.close();
564 ResultSet alternatePlaces = database.executeQuery("SELECT * FROM alternatenames WHERE alternatename is not null");
565
566 while (alternatePlaces.next())
567 {
568 cityList.write(alternatePlaces.getString("alternatename") + "\n");
569 }
570 alternatePlaces.close();
571
572 cityList.close();
573 countryList.close();
574 }
575 catch (Exception ex)
576 {
577 ex.printStackTrace();
578 }
579 }
580
581 public static void RPCTest()
582 {
583 try
584 {
585 String payload = "5|0|4|http://localhost:9090/greenstone3/interfaces/default/js/mapScripts/|FC39F395243F4B8A4145D4DCB673D89A|org.greenstone.client.findPlaceService|isGazetteerLoaded|1|2|3|4|0|";
586
587 URL url = new URL("http://localhost:9090/gpnms/simplemaps/findPlace");
588 HttpURLConnection con = (HttpURLConnection) url.openConnection();
589
590 con.setUseCaches(false);
591 con.setDoOutput(true);
592 con.setDoInput(true);
593 DataOutputStream dataOut = new DataOutputStream(con.getOutputStream());
594 dataOut.write(payload.getBytes());
595 dataOut.flush();
596 dataOut.close();
597 // DataInputStream in = new DataInputStream(con.getInputStream());
598 System.out.println("Content = " + con.getInputStream());
599 }
600 catch (Exception ex)
601 {
602 ex.printStackTrace();
603 System.out.println("Message = " + ex.getMessage());
604 }
605 }
606
607 public void GazetteerTest()
608 {
609 //GazetteerTrieType4 gaz = new GazetteerTrieType4("/home/sam/Desktop/Research/Greenstone3-gate-svn2/web/GPNMS/dataen.txt");
610 GazetteerTrieType5 gaz = new GazetteerTrieType5("/research/sjm84/Msc/Downloads/dataen.txt");
611 initWords();
612 int totalTime = 0;
613 for (int i = 0; i < 100; i++)
614 {
615 Long time = System.currentTimeMillis();
616 try
617 {
618 int count = 0;
619 boolean done = false;
620 while (!done)
621 {
622 StringBuilder currentWords = new StringBuilder();
623
624 int length = 0;
625 while (gaz.checkPlaceName(currentWords.toString()) != -1)
626 {
627 String word = null;
628 if(count + length < _words.size())
629 {
630 word = _words.get(count + length);
631 }
632 if (word == null)
633 {
634 totalTime += System.currentTimeMillis() - time;
635 // _in.close();
636 //System.out.println("DONE");
637 done = true;
638 }
639 if(currentWords.length() == 0)
640 {
641 currentWords.append(word);
642 }
643 else
644 {
645 currentWords.append(" " + word);
646 }
647 length++;
648 }
649 currentWords = new StringBuilder();
650 count++;
651 }
652 }
653 catch (Exception e)
654 {
655 e.printStackTrace();
656 }
657 }
658 System.out.println("Total = " + totalTime / 100);
659 }
660
661 public void initWords()
662 {
663 try
664 {
665 BufferedReader in = new BufferedReader(new FileReader("/home/sjm84/Desktop/placenames.txt"));
666
667 String line = null;
668 while ((line = in.readLine()) != null)
669 {
670 for (String word : line.split(" "))
671 {
672 _words.add(word);
673 _words.add(word);
674 _words.add(word);
675 }
676 }
677 }
678 catch (Exception ex)
679 {
680 ex.printStackTrace();
681 }
682 return;
683 }
684
685
686 public static void PlaceNameCheck()
687 {
688 GazetteerTrieType2 gazetteer = new GazetteerTrieType2("/research/sjm84/Msc/Downloads/dataen.txt");
689
690 try
691 {
692 String inputLine = "";
693 BufferedReader inputStream = new BufferedReader(new InputStreamReader(System.in));
694 while ((inputLine = inputStream.readLine()) != "q")
695 {
696 if (gazetteer.checkPlaceName(inputLine) == 1)
697 {
698 System.out.println(inputLine + " is a place");
699 }
700 else
701 {
702 System.out.println(inputLine + " is not a place");
703 }
704 }
705 }
706 catch (Exception ex)
707 {
708 ex.printStackTrace();
709 }
710 }
711
712 public static void PlacesToPoints()
713 {
714 ArrayList<Float> latitudes = new ArrayList<Float>();
715 ArrayList<Float> longitudes = new ArrayList<Float>();
716 ArrayList<Long> ids = new ArrayList<Long>();
717
718 Statement database = null;
719
720 try
721 {
722 Class.forName("org.postgresql.Driver");
723 Connection c = DriverManager.getConnection("jdbc:postgresql://localhost/GS3MapDB", "postgres", "admin");
724
725 database = c.createStatement();
726
727 ResultSet places = database.executeQuery("SELECT id, latitude, longitude FROM places WHERE latitude is not null");
728
729 while (places.next())
730 {
731 latitudes.add(places.getFloat("latitude"));
732 longitudes.add(places.getFloat("longitude"));
733 ids.add(places.getLong("id"));
734 }
735
736 for (int i = 0; i < latitudes.size(); i++)
737 {
738 System.out.println("INSERT INTO placepoints (id, point) VALUES (" + ids.get(i) + ", GeomFromText('POINT(" + latitudes.get(i) + " " + longitudes.get(i) + ")'));");
739 database.execute("INSERT INTO placepoints (id, point) VALUES (" + ids.get(i) + ", GeomFromText('POINT(" + latitudes.get(i) + " " + longitudes.get(i) + ")'));");
740 }
741
742 System.out.println("lat size = " + latitudes.size());
743 System.out.println("lng size = " + longitudes.size());
744 System.out.println("id size = " + ids.size());
745 }
746 catch (Exception ex)
747 {
748 ex.printStackTrace();
749 }
750 }
751
752 public static void PopulateDatabase()
753 {
754 Statement database = null;
755 try
756 {
757 Class.forName("org.postgresql.Driver");
758 Connection c = DriverManager.getConnection("jdbc:postgresql://localhost/GS3MapDB", "postgres", "admin");
759
760 database = c.createStatement();
761
762 BufferedReader gazetteerFile = new BufferedReader(new FileReader("C:\\Users\\sjm84\\Desktop\\EclipseWorkspace\\ATLAS\\war\\dataen.txt"));
763
764 String line = "";
765 while ((line = gazetteerFile.readLine()) != null)
766 {
767 // The file is tab seperated so split it by tabs
768 String[] columns = line.split("\t");
769
770 String placeName = GazetteerHelper.getMainPlaceName(columns);
771 if (placeName != null)
772 {
773 placeName = placeName.replaceAll("\'", "\\\\\'");
774 }
775 String countryName = GazetteerHelper.getCountryName(columns);
776 if (countryName != null)
777 {
778 countryName = countryName.replaceAll("\'", "\\\\\'");
779 }
780 String regionName = GazetteerHelper.getRegionName(columns);
781 if (regionName != null)
782 {
783 regionName = regionName.replaceAll("\'", "\\\\\'");
784 }
785 String subRegionName = GazetteerHelper.getSubRegionName(columns);
786 if (subRegionName != null)
787 {
788 subRegionName = subRegionName.replaceAll("\'", "\\\\\'");
789 }
790 String placeType = GazetteerHelper.getPlaceType(columns);
791 if (placeType != null)
792 {
793 placeType = placeType.replaceAll("\'", "\\\\\'");
794 }
795 Float latitude = GazetteerHelper.getLatitude(columns);
796 Float longitude = GazetteerHelper.getLongitude(columns);
797 int population = GazetteerHelper.getPopulation(columns);
798 Integer id = GazetteerHelper.getID(columns);
799
800 ArrayList<String> alternatePlaceNames = GazetteerHelper.getAlternativePlaceNames(columns);
801
802 // Because counties do not contain the region information they
803 // are not helpful, so ignore them
804 if (placeName == null || id == null || placeType == null || placeType.equals("county") || placeType.equals("agglomeration"))
805 {
806 continue;
807 }
808
809 try
810 {
811 /*
812 * System.out.println("Inserting ---> \n" +
813 * "INSERT INTO places (id, placename, placetype, subregion, region, country, population, latitude, longitude) VALUES("
814 * + id + ", " + "\'" + placeName + "\'" + ", " + "\'" +
815 * placeType + "\'" + ", " + (subRegionName == null ? "null"
816 * : ("\'" + subRegionName + "\'")) + ", " + (regionName ==
817 * null ? "null" : ("\'" + regionName + "\'")) + ", " +
818 * (countryName == null ? "null" : ("\'" + countryName +
819 * "\'")) + ", " + population + ", " + latitude + ", " +
820 * longitude + ");");
821 */
822 database.execute("INSERT INTO places (id, placename, placetype, subregion, region, country, population, latitude, longitude) VALUES(" + id + ", " + "\'" + placeName + "\'" + ", " + "\'" + placeType + "\'" + ", " + (subRegionName == null ? "null" : ("\'" + subRegionName + "\'")) + ", " + (regionName == null ? "null" : ("\'" + regionName + "\'")) + ", " + (countryName == null ? "null" : ("\'" + countryName + "\'")) + ", " + population + ", " + latitude + ", " + longitude + ");");
823
824 if (alternatePlaceNames != null)
825 {
826 for (String altName : alternatePlaceNames)
827 {
828 if (altName != null)
829 {
830 altName = altName.replaceAll("\'", "\\\\\'");
831 /*
832 * System.out.println("INSERT INTO alternatenames (alternatename, placeindex) VALUES("
833 * + "\'" + altName + "\', " + id + ");");
834 */
835 database.execute("INSERT INTO alternatenames (alternatename, placeindex) VALUES(" + "\'" + altName + "\', " + id + ");");
836 }
837 }
838 }
839 }
840 catch (Exception ex)
841 {
842 ex.printStackTrace();
843 }
844 }
845 }
846 catch (Exception ex)
847 {
848 ex.printStackTrace();
849 }
850 }
851
852 public static void DatabaseFix()
853 {
854 Statement database = null;
855
856 try
857 {
858 Class.forName("org.postgresql.Driver");
859 Connection c = DriverManager.getConnection("jdbc:postgresql://localhost/GS3MapDB", "postgres", "admin");
860
861 database = c.createStatement();
862
863 ResultSet results = database.executeQuery("SELECT * FROM places WHERE population >= 0;");
864
865 ArrayList<String> placeNameList = new ArrayList<String>();
866 ArrayList<String> subRegionList = new ArrayList<String>();
867 ArrayList<String> regionList = new ArrayList<String>();
868 ArrayList<String> countryList = new ArrayList<String>();
869
870 while (results.next())
871 {
872 placeNameList.add(results.getString("placename"));
873 subRegionList.add(results.getString("subregion"));
874 regionList.add(results.getString("region"));
875 countryList.add(results.getString("country"));
876 }
877
878 int counter = 0;
879 while (counter < placeNameList.size())
880 {
881 String placeName = placeNameList.get(counter);
882 String subRegionName = subRegionList.get(counter);
883 String regionName = regionList.get(counter);
884 String countryName = countryList.get(counter);
885
886 System.out.println("* " + counter++ + " " + placeName);
887
888 if (subRegionName != null)
889 {
890 ResultSet subRegionResults = database.executeQuery("SELECT * FROM places WHERE " + "placename = \'" + subRegionName.replaceAll("\'", "\\\\\'") + "\' AND " + "region = \'" + regionName.replaceAll("\'", "\\\\\'") + "\' AND " + "country = \'" + countryName.replaceAll("\'", "\\\\\'") + "\';");
891
892 int count = 0;
893 while (subRegionResults.next())
894 {
895 count++;
896 }
897
898 if (count == 0)
899 {
900 System.out.println("Adding " + subRegionName.replaceAll("\'", "\\\\\'"));
901
902 database.execute("INSERT INTO places (placename, placetype, subregion, region, country, population, latitude, longitude) VALUES(" + "\'" + subRegionName.replaceAll("\'", "\\\\\'") + "\', " + "\'region\', " + "null, " + "\'" + regionName.replaceAll("\'", "\\\\\'") + "\', " + "\'" + countryName.replaceAll("\'", "\\\\\'") + "\', " + "0, " + "null, " + "null);");
903 }
904 }
905
906 if (regionName != null)
907 {
908 ResultSet regionResults = database.executeQuery("SELECT * FROM places WHERE " + "placename = \'" + regionName.replaceAll("\'", "\\\\\'") + "\' AND " + "country = \'" + countryName.replaceAll("\'", "\\\\\'") + "\';");
909
910 int count = 0;
911 while (regionResults.next())
912 {
913 count++;
914 }
915
916 if (count == 0)
917 {
918 System.out.println("Adding " + regionName.replaceAll("\'", "\\\\\'"));
919
920 database.execute("INSERT INTO places (placename, placetype, subregion, region, country, population, latitude, longitude) VALUES(" + "\'" + regionName.replaceAll("\'", "\\\\\'") + "\', " + "\'region\', " + "null, " + "null, " + "\'" + countryName.replaceAll("\'", "\\\\\'") + "\', " + "0, " + "null, " + "null);");
921 }
922 }
923
924 if (countryName != null)
925 {
926 ResultSet countryResults = database.executeQuery("SELECT * FROM places WHERE " + "placename = \'" + countryName.replaceAll("\'", "\\\\\'") + "\';");
927
928 int count = 0;
929 while (countryResults.next())
930 {
931 count++;
932 }
933
934 if (count == 0)
935 {
936 System.out.println("Adding " + countryName.replaceAll("\'", "\\\\\'"));
937
938 database.execute("INSERT INTO places (placename, placetype, subregion, region, country, population, latitude, longitude) VALUES(" + "\'" + countryName.replaceAll("\'", "\\\\\'") + "\', " + "\'country\', " + "null, " + "null, " + "null, " + "0, " + "null, " + "null);");
939 }
940 }
941 }
942 }
943 catch (Exception ex)
944 {
945 ex.printStackTrace();
946 }
947 }
948
949 public ScanResultSet getCorrectScanResultSet(int index)
950 {
951 ScanResultSet correctResultSet = null;
952
953 if (index == 0)
954 {
955 correctResultSet = new ScanResultSet("australia", new Long[] { new Long(-24), /* Australia */
956 new Long(196916913), /* Canberra */
957 new Long(202101121), /* Sydney */
958 new Long(-81), /* UK */
959 new Long(-435), /* Tasmania */
960 new Long(-101), /* Indonesia */
961 new Long(-214), /* East_Timor */
962 new Long(-170), /* PNG */
963 new Long(-186), /* Solomon_Islands */
964 new Long(-232), /* Vanuatu */
965 new Long(-155), /* New_Caledonia */
966 new Long(-165), /* New_Zealand */
967 new Long(187916496), /* Melbourne */
968 new Long(225177302), /* Brisbane */
969 new Long(208973584), /* Perth */
970 new Long(198283860), /* Adelaide */
971 new Long(279283085), /* Darwin */
972 new Long(-431), /* NSW */
973 new Long(-430), /* ACT */
974 new Long(301780683), /* Jakarta */
975 new Long(-160), /* Netherlands */
976 new Long(-1495), /* England */
977 new Long(-434), /* South_Australia */
978 new Long(-436), /* Victoria */
979 new Long(-433), /* Queensland */
980 new Long(-432), /* Northern_Territory */
981 new Long(-437), /* WA */
982 new Long(469532668), /* Gelibolu(Gallipoli) */
983 new Long(-223), /* Christmas_Island */
984 new Long(-3902), /* Cocos_Islands */
985 new Long(-3900), /* Ashmore_and_Cartier */
986 new Long(-3903), /* Coral_Sea_Islands */
987 new Long(-157), /* Norfolk_Island */
988 new Long(263120575), /* Cairns */
989 new Long(-111), /* Japan */
990 new Long(-152), /* Malaysia */
991 new Long(-190), /* Singapore */
992 new Long(-45), /* Canada */
993 new Long(-188), /* Sudan */
994 new Long(-105), /* Iraq */
995 new Long(-161), /* Norway */
996 new Long(-155), /* Kiribati */
997 new Long(-163), /* Nauru */
998 new Long(-217), /* Tuvalu */
999 new Long(-54), /* China */
1000 new Long(-108), /* Italy */
1001 new Long(-231), /* Vietnam */
1002 new Long(222981344), /* Gold_Coast */
1003 new Long(205521175), /* Newcastle */
1004 new Long(196772922), /* Queanbeyan */
1005 new Long(200121087), /* Wollongong */
1006 new Long(230865256), /* Sunshine_Coast */
1007 new Long(169772729), /* Hobart */
1008 new Long(186728432), /* Geelong */
1009 new Long(254696678), /* Townsville */
1010 new Long(224817196), /* Toowoomba */
1011 new Long(174812713), /* Launceston */
1012 new Long(194216692), /* Albury */
1013 new Long(193964688), /* Wodonga */
1014 new Long(188816384), /* Ballarat */
1015 new Long(191696428), /* Bendigo */
1016 new Long(-126), /* Liechtenstein */
1017 new Long(-63), /* Denmark */
1018 new Long(-972), /* Aomen */
1019 new Long(-32), /* Bulgaria */
1020 new Long(-79), /* France */
1021 new Long(-140), /* Mali */
1022 new Long(-189), /* Sweden */
1023 new Long(-131), /* Luxembourg */
1024 new Long(510353874), /* Oxford */
1025 new Long(511974013), /* Cambridge */
1026 // new Long(509489990), /* London */
1027 new Long(-75), /* Fiji */
1028 new Long(-77), /* Micronesia */
1029 new Long(-138), /* Marshall Islands */
1030 new Long(-178), /* Palau */
1031 new Long(-234), /* Samoa */
1032 new Long(-213), /* Tonga */
1033 new Long(-232), /* Vanuatu */
1034 new Long(-169), /* French Polynesia */
1035 new Long(-155), /* New Caledonia */
1036 new Long(-233), /* Wallis and Futuna */
1037 new Long(-51), /* Cook Islands */
1038 new Long(-164), /* Niue */
1039 new Long(-210), /* Tokelau */
1040 new Long(-3912), /* Pitcairn */
1041 new Long(-22), /* American Samoa */
1042 new Long(-94), /* Guam */
1043 new Long(-3767), /* Hawaii */
1044 new Long(-143), /* Chile */
1045 new Long(-3907), /* Easter Island */
1046 new Long(-102), /* Ireland */
1047 new Long(-239), /* Isle of Man */
1048 new Long(-238), /* Jersey */
1049 new Long(-147), /* Malta */
1050 new Long(-14), /* Antigua and Barbuda */
1051 new Long(-40), /* Bahamas */
1052 new Long(-28), /* Barbados */
1053 new Long(-64), /* Dominica */
1054 new Long(-96), /* Guyana */
1055 new Long(-109), /* Jamaica */
1056 new Long(-117), /* Saint Kitts and Nevis */
1057 new Long(-227), /* Saint Vincent and The Grenadines */
1058 new Long(-216), /* Trinidad and Tobago */
1059 new Long(-44), /* Belize */
1060 new Long(-82), /* Grenada */
1061 new Long(-125), /* Saint Lucia */
1062 new Long(-37), /* Brunei */
1063 new Long(-185), /* Saudi Arabia */
1064 new Long(-203), /* Swaziland */
1065 new Long(-226), /* Vatican City */
1066 new Long(-11), /* Andorra */
1067 new Long(-33), /* Bahrain */
1068 new Long(-30), /* Belgium */
1069 new Long(-41), /* Bhutan */
1070 new Long(-114), /* Cambodia */
1071 new Long(-110), /* Jordan */
1072 new Long(-120), /* Kuwait */
1073 new Long(-129), /* Lesothol */
1074 new Long(-152), /* Malaysia */
1075 new Long(-135), /* Monaco */
1076 new Long(-134), /* Morocco */
1077 new Long(-166), /* Oman */
1078 new Long(-180), /* Qatar */
1079 new Long(-72), /* Spain */
1080 new Long(-208), /* Thailand */
1081 new Long(-12), /* United Arab Emirates */
1082 new Long(-85), /* Ghana */
1083 new Long(-1520), /* Ashanti */
1084 new Long(-2608), /* Johor */
1085 new Long(-2609), /* Kedah */
1086 new Long(-2610), /* Kelantan */
1087 new Long(-2614), /* Negeri Sembilan */
1088 new Long(-2615), /* Pahang */
1089 new Long(-2616), /* Perak */
1090 new Long(-2617), /* Perlis */
1091 new Long(-2621), /* Selangor */
1092 new Long(-2622), /* Terengganu */
1093 new Long(-158), /* Nigeria */
1094 new Long(350586393), /* Ibadan */
1095 new Long(-2677), /* Kano */
1096 new Long(-2691), /* Sokoto */
1097 new Long(-2682), /* Lagos */
1098 new Long(-221), /* Uganda */
1099 new Long(-265), /* Abu Dhabi */
1100 new Long(-267), /* Dubai */
1101 new Long(-270), /* Sharjah */
1102 new Long(-3891), /* Wallis and Futuna */
1103 new Long(-3895), /* Sigave */
1104 new Long(-246), /* Zambia */
1105 new Long(-245), /* South Africa */
1106 new Long(-29), /* Bangladesh */
1107 new Long(-42), /* Botswana */
1108 new Long(-53), /* Cameroon */
1109 new Long(-59), /* Cyprus */
1110 new Long(-88), /* Gambia */
1111 new Long(-104), /* India */
1112 new Long(-112), /* Kenya */
1113 new Long(-150), /* Malawi */
1114 new Long(-149), /* Maldives */
1115 new Long(-148), /* Mauritius */
1116 new Long(-153), /* Mozambique */
1117 new Long(-154), /* Namibia */
1118 new Long(-172), /* Pakistan */
1119 new Long(-187), /* Seychelles */
1120 new Long(-195), /* Sierra Leone */
1121 new Long(-127), /* Sri Lanka */
1122 new Long(-219), /* Tanzania */
1123 });
1124 }
1125 else if (index == 1)
1126 {
1127 correctResultSet = new ScanResultSet("canada", new Long[] { new Long(-3795), /*
1128 * Rhode
1129 * Island
1130 */
1131 new Long(-433), /* Queensland */
1132 new Long(-159), /* Nicaragua */
1133 new Long(-13), /* Afghanistan */
1134 new Long(-3785), /* New Hampshire */
1135 new Long(-3774), /* Louisiana */
1136 new Long(-121), /* Cayman Islands */
1137 new Long(498353663), /* Victoria */
1138 new Long(-3780), /* Mississippi */
1139 new Long(-96), /* Guyana */
1140 new Long(-115), /* Kiribati */
1141 new Long(-123), /* Laos */
1142 new Long(-90), /* Guadeloupe */
1143 new Long(-201), /* El Salvador */
1144 new Long(-126), /* Liechtenstein */
1145 new Long(474823250), /* Rome */
1146 new Long(-174), /* Saint Pierre and Miquelon */
1147 new Long(-47), /* Central African Republic */
1148 new Long(-838), /* British Columbia */
1149 new Long(490475686), /* Charlottetown */
1150 new Long(487450810), /* Sherbrooke */
1151 new Long(511747334), /* Saskatoon */
1152 new Long(-218), /* Taiwan */
1153 new Long(-149), /* Maldives */
1154 new Long(-220), /* Ukraine */
1155 new Long(503576283), /* Winnipeg */
1156 new Long(-3765), /* Florida */
1157 new Long(-837), /* Alberta */
1158 new Long(-108), /* Italy */
1159 new Long(-136), /* Moldova */
1160 new Long(-3901), /* Christmas Island */
1161 new Long(-59), /* Cyprus */
1162 new Long(-233), /* Wallis and Futuna */
1163 new Long(480465950), /* Kitchener */
1164 new Long(-51), /* Cook Islands */
1165 new Long(-849), /* Yukon */
1166 new Long(-91), /* Equatorial Guinea */
1167 new Long(-6751), /* Paris */
1168 new Long(-98), /* Croatia */
1169 new Long(-848), /* Saskatchewan */
1170 new Long(476289697), /* Windsor */
1171 new Long(-435), /* Tasmania */
1172 new Long(-189), /* Sweden */
1173 new Long(-144), /* Martinique */
1174 new Long(-204), /* Turks and Caicos Islands */
1175 new Long(-2614), /* Negeri Sembilan */
1176 new Long(-844), /* Nunavut */
1177 new Long(-168), /* Peru */
1178 new Long(-88), /* Gambia */
1179 new Long(-3767), /* Hawaii */
1180 new Long(-187), /* Seychelles */
1181 new Long(-221), /* Uganda */
1182 new Long(-207), /* Togo */
1183 new Long(-188), /* Sudan */
1184 new Long(-40), /* Bahamas */
1185 new Long(-216), /* Trinidad and Tobago */
1186 new Long(-246), /* Zambia */
1187 new Long(-65), /* Dominican Republic */
1188 new Long(-48), /* Congo */
1189 new Long(-177), /* Portugal */
1190 new Long(-999), /* Hong Kong */
1191 new Long(484823639), /* Halifax */
1192 new Long(-75), /* Fiji Islands */
1193 new Long(-164), /* Niue */
1194 new Long(520998673), /* Athabasca */
1195 new Long(-234), /* Samoa */
1196 new Long(-215), /* Turkey */
1197 new Long(-3900), /* Ashmore and Cartier */
1198 new Long(472726708), /* New Haven */
1199 new Long(505627539), /* Regina */
1200 new Long(-205), /* Chad */
1201 new Long(-182), /* Romania */
1202 new Long(-84), /* French Guiana */
1203 new Long(-137), /* Madagascar */
1204 new Long(-116), /* Comoros */
1205 new Long(-185), /* Saudi Arabia */
1206 new Long(-102), /* Ireland */
1207 new Long(-1495), /* England */
1208 new Long(481150062), /* Toronto */
1209 new Long(-152), /* Malaysia */
1210 new Long(-25), /* Aruba */
1211 new Long(-245), /* South Africa */
1212 new Long(489826804), /* Victoriaville */
1213 new Long(-135), /* Monaco */
1214 new Long(-145), /* Mauritania */
1215 new Long(-3762), /* Connecticut */
1216 new Long(-2620), /* Sarawak */
1217 new Long(-840), /* New Brunswick */
1218 new Long(-20), /* Antarctica */
1219 new Long(-173), /* Poland */
1220 new Long(-3757), /* Alaska */
1221 new Long(-32), /* Bulgaria */
1222 new Long(-83), /* Georgia */
1223 new Long(-61), /* Germany */
1224 new Long(-161), /* Norway */
1225 new Long(-57), /* Cuba */
1226 new Long(-56), /* Costa Rica */
1227 new Long(-104), /* India */
1228 new Long(-594), /* Luxemburg */
1229 new Long(-197), /* Senegal */
1230 new Long(-3777), /* Massachusetts */
1231 new Long(-2621), /* Selangor */
1232 new Long(-3776), /* Maryland */
1233 new Long(-154), /* Namibia */
1234 new Long(-846), /* Prince Edward Island */
1235 new Long(-845), /* Ontario */
1236 new Long(-125), /* Saint Lucia */
1237 new Long(-3788), /* New York */
1238 new Long(477873552), /* East Lansing */
1239 new Long(-3794), /* Pennsylvania */
1240 new Long(-3840), /* Grenadines */
1241 new Long(-217), /* Tuvalu */
1242 new Long(-72), /* Spain */
1243 new Long(-437), /* Western Australia */
1244 new Long(523014522), /* Slave Lake */
1245 new Long(-97), /* Honduras */
1246 new Long(-2612), /* Labuan */
1247 new Long(-76), /* Falkland Islands */
1248 new Long(-109), /* Jamaica */
1249 new Long(-2622), /* Terengganu */
1250 new Long(-42), /* Botswana */
1251 new Long(-171), /* Philippines */
1252 new Long(-134), /* Morocco */
1253 new Long(-99), /* Haiti */
1254 new Long(-79), /* France */
1255 new Long(-175), /* Puerto Rico */
1256 new Long(-2615), /* Pahang */
1257 new Long(-58), /* Cape Verde */
1258 new Long(-132), /* Latvia */
1259 new Long(-167), /* Panama */
1260 new Long(-34), /* Burundi */
1261 new Long(-2609), /* Kedah */
1262 new Long(504473703), /* Whistler */
1263 new Long(-227), /* Saint Vincent and The Grenadines */
1264 new Long(-151), /* Mexico */
1265 new Long(479746015), /* Hamilton */
1266 new Long(-138), /* Marshall Islands */
1267 new Long(-107), /* Iceland */
1268 new Long(-124), /* Lebanon */
1269 new Long(-129), /* Lesotho */
1270 new Long(-157), /* Norfolk Island */
1271 new Long(479134098), /* Niagara Falls */
1272 new Long(-229), /* British Virgin Islands */
1273 new Long(-192), /* Slovenia */
1274 new Long(-9192), /* Washington */
1275 new Long(-146), /* Montserrat */
1276 new Long(-31), /* Burkina Faso */
1277 new Long(-69), /* Egypt */
1278 new Long(501413687), /* Vancouver */
1279 new Long(-183), /* Russia */
1280 new Long(-165), /* New Zealand */
1281 new Long(-194), /* Slovakia */
1282 new Long(477765545), /* Lansing */
1283 new Long(-92), /* Greece */
1284 new Long(-208), /* Thailand */
1285 new Long(-213), /* Tonga */
1286 new Long(485470468), /* Iroquois */
1287 new Long(-77), /* Micronesia */
1288 new Long(-63), /* Denmark */
1289 new Long(-120), /* Kuwait */
1290 new Long(-226), /* Vatican City */
1291 new Long(-172), /* Pakistan */
1292 new Long(-3802), /* Virginia */
1293 new Long(-2616), /* Perak */
1294 new Long(-842), /* Northwest Territories */
1295 new Long(482014114), /* Oshawa */
1296 new Long(-53), /* Cameroon */
1297 new Long(-3778), /* Michigan */
1298 new Long(-3786), /* New Jersey */
1299 new Long(-247), /* Zimbabwe */
1300 new Long(-244), /* Serbia */
1301 new Long(-68), /* Estonia */
1302 new Long(488639613), /* Oxford */
1303 new Long(-186), /* Solomon Islands */
1304 new Long(-112), /* Kenya */
1305 new Long(-150), /* Malawi */
1306 new Long(-212), /* Tunisia */
1307 new Long(-54), /* China */
1308 new Long(-1520), /* Ashanti */
1309 new Long(523157692), /* Mackenzie */
1310 new Long(-3875), /* Saint Croix */
1311 new Long(-114), /* Cambodia */
1312 new Long(487882643), /* Montreal */
1313 new Long(-3789), /* North Carolina */
1314 new Long(-101), /* Indonesia */
1315 new Long(-2610), /* Kelantan */
1316 new Long(-52), /* Chile */
1317 new Long(-33), /* Bahrain */
1318 new Long(483490166), /* Peterborough */
1319 new Long(-176), /* Palestine */
1320 new Long(-166), /* Oman */
1321 new Long(-839), /* Manitoba */
1322 new Long(492022827), /* Donnacona */
1323 new Long(-156), /* Niger */
1324 new Long(-18), /* Netherlands Antilles */
1325 new Long(-3903), /* Coral Sea Islands */
1326 new Long(-60), /* Czech Republic */
1327 new Long(-843), /* Nova Scotia */
1328 new Long(-3753), /* Navassa Island */
1329 new Long(-847), /* Quebec */
1330 new Long(-841), /* Newfoundland and Labrador */
1331 new Long(-49), /* Switzerland */
1332 new Long(478701876), /* London */
1333 new Long(-3793), /* Oregon */
1334 new Long(516858646), /* Edmonton */
1335 new Long(-23), /* Austria */
1336 new Long(-1376), /* South Sandwich Islands */
1337 new Long(-100), /* Hungary */
1338 new Long(-36), /* Bermuda */
1339 new Long(-148), /* Mauritius */
1340 new Long(-21), /* Argentina */
1341 new Long(-210), /* Tokelau */
1342 new Long(511567873), /* Swan River */
1343 new Long(-111), /* Japan */
1344 new Long(-12), /* United Arab Emirates */
1345 new Long(-431), /* New South Wales */
1346 new Long(-3796), /* South Carolina */
1347 new Long(-127), /* Sri Lanka */
1348 new Long(-3902), /* Cocos Islands */
1349 new Long(-87), /* Greenland */
1350 new Long(-139), /* Macedonia */
1351 new Long(-110), /* Jordan */
1352 new Long(-3791), /* Ohio */
1353 new Long(507786594), /* Calgary */
1354 new Long(-117), /* Saint Kitts and Nevis */
1355 new Long(-184), /* Rwanda */
1356 new Long(-203), /* Swaziland */
1357 new Long(-238), /* Jersey */
1358 new Long(487522429), /* Ottawa */
1359 new Long(-434), /* South Australia */
1360 new Long(-180), /* Qatar */
1361 new Long(458717784), /* Stanford */
1362 new Long(-178), /* Palau */
1363 new Long(-41), /* Bhutan */
1364 new Long(-231), /* Vietnam */
1365 new Long(-24), /* Australia */
1366 new Long(-160), /* Netherlands */
1367 new Long(-86), /* Gibraltar */
1368 new Long(-3763), /* Delaware */
1369 new Long(-239), /* Isle of Man */
1370 new Long(-130), /* Lithuania */
1371 new Long(-199), /* Suriname */
1372 new Long(514267762), /* Hudson Bay */
1373 new Long(-82), /* Grenada */
1374 new Long(-190), /* Singapore */
1375 new Long(-95), /* Guinea-Bissau */
1376 });
1377 }
1378 else if (index == 2)
1379 {
1380 correctResultSet = new ScanResultSet("ireland", new Long[] { new Long(-1395), /* Asturias */
1381 new Long(512693027), /* Causeway */
1382 new Long(510137147), /* Kinsale */
1383 new Long(516005375), /* Dublin */
1384 new Long(515609332), /* Naas */
1385 new Long(-1496), /* Northern Ireland */
1386 new Long(518489358), /* Dundalk */
1387 new Long(474823250), /* Rome */
1388 new Long(512441352), /* Wexford */
1389 new Long(513737108), /* Shannon */
1390 // new Long(521009377), /* Antrim */
1391 new Long(514925071), /* Lisdoonvarna */
1392 new Long(-108), /* Italy */
1393 new Long(517121180), /* Roscommon */
1394 new Long(514097385), /* Arklow */
1395 new Long(519065365), /* Newry */
1396 new Long(-1497), /* Scotland */
1397 new Long(518561381), /* Carlingford */
1398 // new Long(519677333), /* Armagh */
1399 new Long(-1298), /* Galicia */
1400 new Long(514781395), /* Wicklow */
1401 new Long(522809335), /* Portrush */
1402 new Long(512477258), /* Carrick-on-Suir */
1403 new Long(-999), /* Hong Kong */
1404 new Long(517445219), /* Longford */
1405 new Long(-234), /* Samoa */
1406 new Long(514853389), /* Ashford */
1407 new Long(-102), /* Ireland */
1408 new Long(517625108), /* Knock */
1409 new Long(-1399), /* Barcelona */
1410 new Long(-1495), /* England */
1411 new Long(515825094), /* Galway */
1412 new Long(202101121), /* Sydney */
1413 new Long(512153287), /* Waterford */
1414 new Long(515393301), /* Kildare */
1415 new Long(-104), /* India */
1416 new Long(516725266), /* Mullingar */
1417 new Long(512981183), /* Tipperary */
1418 new Long(514745251), /* Castletown */
1419 new Long(510713170), /* Cobh */
1420 new Long(-1498), /* Wales */
1421 new Long(-3788), /* New York */
1422 new Long(519389141), /* Strandhill */
1423 new Long(517193331), /* Navan */
1424 new Long(-72), /* Spain */
1425 new Long(514241308), /* Carlow */
1426 new Long(520145171), /* Bundoran */
1427 new Long(513593274), /* Kilkenny */
1428 new Long(520793188), /* Donegal */
1429 new Long(519317303), /* Monaghan */
1430 new Long(478665434), /* Grand Rapids */
1431 new Long(519425152), /* Sligo */
1432 new Long(-81), /* United Kingdom */
1433 new Long(512045133), /* Buttevant */
1434 new Long(514601065), /* Lahinch */
1435 new Long(-79), /* France */
1436 new Long(-45), /* Canada */
1437 new Long(512513229), /* Clonmel */
1438 // new Long(520577407), /* Belfast */
1439 new Long(522017267), /* Londonderry */
1440 new Long(517409364), /* Drogheda */
1441 new Long(513017343), /* Enniscorthy */
1442 new Long(511037215), /* Youghal */
1443 new Long(-165), /* New Zealand */
1444 new Long(518237346), /* Louth */
1445 new Long(-3802), /* Virginia */
1446 new Long(527417729), /* Carnoustie */
1447 new Long(-3786), /* New Jersey */
1448 new Long(-247), /* Zimbabwe */
1449 new Long(516545775), /* Manchester */
1450 new Long(515897124), /* Athenry */
1451 new Long(510353874), /* Oxford */
1452 new Long(514061177), /* Silvermines */
1453 new Long(470674597), /* Hoboken */
1454 new Long(513089211), /* Cashel */
1455 new Long(520793432), /* Bangor */
1456 new Long(512657305), /* New Ross */
1457 new Long(509993050), /* Bantry */
1458 new Long(-101), /* Indonesia */
1459 new Long(513701217), /* Thurles */
1460 // new Long(520289394), /* Lisburn */
1461 new Long(511001143), /* Blarney */
1462 new Long(511684975), /* Dingle */
1463 new Long(-3139), /* Moscow */
1464 new Long(516797320), /* Trim */
1465 new Long(-6055), /* London */
1466 new Long(-6030), /* Cornwall */
1467 new Long(-111), /* Japan */
1468 // new Long(521477418), /* Larne */
1469 new Long(-87), /* Greenland */
1470 new Long(510929183), /* Midleton */
1471 new Long(510857153), /* Cork */
1472 new Long(-228), /* Venezuela */
1473 new Long(518417263), /* Cavan */
1474 new Long(513629137), /* Limerick */
1475 new Long(514349180), /* Nenagh */
1476 new Long(-24), /* Australia */
1477 new Long(-256907), /* Killarney */
1478 new Long(-239), /* Isle of Man */
1479 new Long(497323158), /* Munich */
1480 // new Long(522485331), /* Coleraine */
1481 });
1482 }
1483 else if (index == 3)
1484 {
1485 correctResultSet = new ScanResultSet("southafrica", new Long[] { new Long(-245), /*
1486 * South
1487 * Africa
1488 */
1489 new Long(231392822), /* Pretoria */
1490 new Long(219080623), /* Bloemfontein */
1491 new Long(201871846), /* Cape Town */
1492 new Long(229736804), /* Johannesburg */
1493 new Long(-81), /* United Kingdom */
1494 new Long(-154), /* Namibia */
1495 new Long(-42), /* Botswana */
1496 new Long(-153), /* Mozambique */
1497 new Long(-203), /* Swaziland */
1498 new Long(-129), /* Lesotho */
1499 new Long(-3991), /* KwaZulu Natal */
1500 new Long(-3988), /* Eastern Cape */
1501 new Long(-101), /* Indonesia */
1502 new Long(-137), /* Madagascar */
1503 new Long(-24), /* Australia */
1504 new Long(-101), /* Indonesia */
1505 new Long(-104), /* India */
1506 new Long(-3990), /* Gauteng */
1507 new Long(-3992), /* Limpopo */
1508 new Long(-3993), /* Mpumalanga */
1509 new Long(-3995), /* North West */
1510 new Long(-34), /* Burundi */
1511 new Long(-116), /* Comoros */
1512 new Long(-247), /* Zimbabwe */
1513 new Long(-3994), /* Northern Cape */
1514 new Long(-3989), /* Free State */
1515 new Long(-3996), /* Western Cape */
1516 new Long(205688739), /* Bhisho */
1517 new Long(217425039), /* Pietermaritzburg */
1518 new Long(238016945), /* Polokwane */
1519 new Long(232329098), /* Nelspruit */
1520 new Long(220520477), /* Kimberley */
1521 new Long(238016945), /* Polokwane */
1522 new Long(231032561), /* Mmabatho */
1523 new Long(-55), /* Colombia */
1524 new Long(-78614), /* Sutherland */
1525 new Long(221564123), /* Upington */
1526 new Long(203132219), /* Oudtshoorn */
1527 new Long(-39), /* Brazil */
1528 new Long(-54), /* China */
1529 new Long(-151), /* Mexico */
1530 new Long(201764559), /* Port Elizabeth */
1531 new Long(-133), /* Libya */
1532 new Long(216489099), /* Durban */
1533 new Long(-148), /* Mauritius */
1534 new Long(-150), /* Malawi */
1535 new Long(-61), /* Germany */
1536 new Long(-111), /* Japan */
1537 new Long(-72), /* Spain */
1538 new Long(201907886), /* Stellenbosch */
1539 new Long(202699896), /* Paarl */
1540 new Long(-79), /* France */
1541 new Long(445545558), /* Atlanta */
1542 new Long(-14), /* Antigua and Barbuda */
1543 new Long(-40), /* Bahamas */
1544 new Long(-28), /* Barbados */
1545 new Long(-64), /* Dominica */
1546 new Long(-96), /* Guyana */
1547 new Long(-109), /* Jamaica */
1548 new Long(-117), /* Saint Kitts and Nevis */
1549 new Long(-227), /* Saint Vincent and The Grenadines */
1550 new Long(-216), /* Trinidad and Tobago */
1551 new Long(-44), /* Belize */
1552 new Long(-82), /* Grenada */
1553 new Long(-125), /* Saint Lucia */
1554 new Long(-37), /* Brunei */
1555 new Long(-185), /* Saudi Arabia */
1556 new Long(-203), /* Swaziland */
1557 new Long(-33), /* Bahrain */
1558 new Long(-30), /* Belgium */
1559 new Long(-120), /* Kuwait */
1560 new Long(-129), /* Lesothol */
1561 new Long(-152), /* Malaysia */
1562 new Long(-134), /* Morocco */
1563 new Long(-166), /* Oman */
1564 new Long(-180), /* Qatar */
1565 new Long(-72), /* Spain */
1566 new Long(-208), /* Thailand */
1567 new Long(-12), /* United Arab Emirates */
1568 new Long(-85), /* Ghana */
1569 new Long(-158), /* Nigeria */
1570 new Long(-221), /* Uganda */
1571 new Long(-246), /* Zambia */
1572 });
1573 }
1574 else if (index == 4)
1575 {
1576 correctResultSet = new ScanResultSet("washington", new Long[] { new Long(-3795), /*
1577 * Rhode
1578 * Island
1579 */
1580 new Long(498317769), /* Mount Vernon */
1581 new Long(-3750), /* Johnston Atoll */
1582 new Long(-3785), /* New Hampshire */
1583 new Long(-3774), /* Louisiana */
1584 new Long(-3780), /* Mississippi */
1585 new Long(496193763), /* Edmonds */
1586 new Long(498605777), /* Sedro-Woolley */
1587 new Long(493781747), /* Lakewood */
1588 new Long(491729947), /* Yakima */
1589 new Long(492197704), /* Centralia */
1590 new Long(-838), /* British Columbia */
1591 new Long(495113796), /* Issaquah */
1592 new Long(493349711), /* Olympia */
1593 new Long(493205945), /* Ellensburg */
1594 new Long(-3797), /* South Dakota */
1595 new Long(494970242), /* Cheney */
1596 new Long(493961689), /* Shelton */
1597 new Long(-3765), /* Florida */
1598 new Long(-3756), /* Alabama */
1599 new Long(494321766), /* Federal Way */
1600 new Long(496661780), /* Everett */
1601 new Long(-3768), /* Idaho */
1602 new Long(-3748), /* Howland Island */
1603 new Long(495618259), /* Spokane */
1604 new Long(496049769), /* Mountlake Terrace */
1605 new Long(-849), /* Yukon */
1606 new Long(495257777), /* Mercer Island */
1607 new Long(489858166), /* Walla Walla */
1608 new Long(-3747), /* Baker Island */
1609 new Long(-3771), /* Iowa */
1610 new Long(-3790), /* North Dakota */
1611 new Long(-3770), /* Indiana */
1612 new Long(-3779), /* Minnesota */
1613 new Long(490362023), /* Prosser */
1614 new Long(-3767), /* Hawaii */
1615 new Long(-3782), /* Montana */
1616 new Long(495581748), /* Bainbridge Island */
1617 new Long(495618276), /* Spokane Valley */
1618 new Long(496229998), /* Chelan */
1619 new Long(490830295), /* Asotin */
1620 new Long(-3787), /* New Mexico */
1621 new Long(488957885), /* Klickitat */
1622 new Long(494717971), /* East Wenatchee */
1623 new Long(-3760), /* California */
1624 new Long(493205708), /* Tumwater */
1625 new Long(496949759), /* Langley */
1626 new Long(490326083), /* Kennewick */
1627 new Long(492809731), /* Rainier */
1628 new Long(497849738), /* Oak Harbor */
1629 new Long(-3755), /* Wake */
1630 new Long(494645769), /* Des Moines */
1631 new Long(496698102), /* Coulee Dam */
1632 new Long(495365784), /* Bellevue */
1633 new Long(498569737), /* Anacortes */
1634 new Long(496590100), /* Grand Coulee */
1635 new Long(490865595), /* Long Beach */
1636 new Long(490757999), /* Sunnyside */
1637 new Long(-3762), /* Connecticut */
1638 new Long(494537790), /* Covington */
1639 new Long(-3758), /* Arizona */
1640 new Long(-3757), /* Alaska */
1641 new Long(-3783), /* Nebraska */
1642 new Long(495653781), /* Kirkland */
1643 new Long(-3777), /* Massachusetts */
1644 new Long(494933780), /* Renton */
1645 new Long(-3776), /* Maryland */
1646 new Long(496193770), /* Lynnwood */
1647 new Long(-3801), /* Vermont */
1648 new Long(496553769), /* Mukilteo */
1649 new Long(-3788), /* New York */
1650 new Long(495185730), /* Bremerton */
1651 new Long(490650065), /* West Richland */
1652 new Long(494285779), /* Auburn */
1653 new Long(-3761), /* Colorado */
1654 new Long(-3794), /* Pennsylvania */
1655 new Long(491045974), /* Zillah */
1656 new Long(488813747), /* Battle Ground */
1657 new Long(-3784), /* Nevada */
1658 new Long(490506087), /* Pasco */
1659 new Long(494537796), /* Maple Valley */
1660 new Long(495905764), /* Shoreline */
1661 new Long(498786210), /* Colville */
1662 new Long(495941776), /* Kenmore */
1663 new Long(453969645), /* New Market */
1664 new Long(493853772), /* Puyallup */
1665 new Long(494933773), /* Tukwila */
1666 new Long(493133958), /* Kittitas */
1667 new Long(-3798), /* Tennessee */
1668 new Long(487949734), /* Portland */
1669 new Long(-151), /* Mexico */
1670 new Long(-45), /* Canada */
1671 new Long(-3775), /* Maine */
1672 new Long(494789770), /* SeaTac */
1673 new Long(495005821), /* North Bend */
1674 new Long(495293790), /* Sammamish */
1675 new Long(-3805), /* Wisconsin */
1676 new Long(-9192), /* Washington */
1677 new Long(496301780), /* Mill Creek */
1678 new Long(493925801), /* Enumclaw */
1679 new Long(490073711), /* Kelso */
1680 new Long(488273736), /* Vancouver */
1681 new Long(-183), /* Russia */
1682 new Long(495941780), /* Bothell */
1683 new Long(499469753), /* Bellingham */
1684 new Long(-3802), /* Virginia */
1685 new Long(497021785), /* Marysville */
1686 new Long(-3799), /* Texas */
1687 new Long(494105754), /* Tacoma */
1688 new Long(-3778), /* Michigan */
1689 new Long(-3786), /* New Jersey */
1690 new Long(-3759), /* Arkansas */
1691 new Long(493925906), /* Cle Elum */
1692 new Long(495149736), /* Port Orchard */
1693 new Long(493601742), /* Fort Lewis */
1694 new Long(494861765), /* Burien */
1695 new Long(493638071), /* Moses Lake */
1696 new Long(497525788), /* Arlington */
1697 new Long(496517791), /* Snohomish */
1698 new Long(493242286), /* Garfield */
1699 new Long(-8340), /* District of Columbia */
1700 new Long(-3749), /* Jarvis Island */
1701 new Long(-3789), /* North Carolina */
1702 new Long(497489654), /* Port Angeles */
1703 new Long(-101), /* Indonesia */
1704 new Long(490650071), /* Richland */
1705 new Long(495617789), /* Redmond */
1706 new Long(-3806), /* Wyoming */
1707 new Long(-3772), /* Kansas */
1708 new Long(498102042), /* Okanogan */
1709 new Long(-3753), /* Navassa Island */
1710 new Long(493133619), /* Aberdeen */
1711 new Long(-3781), /* Missouri */
1712 new Long(495905789), /* Woodinville */
1713 new Long(493997746), /* University Place */
1714 new Long(-3793), /* Oregon */
1715 new Long(-3769), /* Illinois */
1716 new Long(495365934), /* Leavenworth */
1717 new Long(494753968), /* Wenatchee */
1718 new Long(-3773), /* Kentucky */
1719 new Long(-3800), /* Utah */
1720 new Long(-3796), /* South Carolina */
1721 new Long(488093765), /* Washougal */
1722 new Long(494609776), /* Kent */
1723 new Long(495437765), /* Seattle */
1724 new Long(496301801), /* Monroe */
1725 new Long(-3791), /* Ohio */
1726 new Long(-3804), /* West Virginia */
1727 new Long(-3751), /* Kingman Reef */
1728 new Long(490145705), /* Longview */
1729 new Long(490506009), /* Grandview */
1730 new Long(492234284), /* Pullman */
1731 new Long(500225754), /* Lynden */
1732 new Long(493889783), /* Bonney Lake */
1733 new Long(495941771), /* Lake Forest Park */
1734 new Long(-3763), /* Delaware */
1735 new Long(488129758), /* Camas */
1736 new Long(493313719), /* Lacey */
1737 new Long(-3792), /* Oklahoma */
1738 });
1739 }
1740 return correctResultSet;
1741 }
1742}
Note: See TracBrowser for help on using the repository browser.