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

Last change on this file since 22272 was 22272, checked in by sjm84, 14 years ago

Initial version of ATLAS as an extension

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