diff --git a/readme.mediawiki b/readme.mediawiki
index 7060eb65c..c3f8a887d 100644
--- a/readme.mediawiki
+++ b/readme.mediawiki
@@ -52,7 +52,7 @@ all these locations into one search result.
== DEPENDENCIES? WHAT OTHER SOFTWARE DO I NEED? ==
-You need java 1.6 or later to run YaCy, nothing else.
+You need java 1.7 or later to run YaCy, nothing else.
Please download it from http://www.java.com
YaCy also runs on IcedTea6.
diff --git a/source/net/yacy/data/wiki/WikiCode.java b/source/net/yacy/data/wiki/WikiCode.java
index 4459b0640..0dad95d5a 100644
--- a/source/net/yacy/data/wiki/WikiCode.java
+++ b/source/net/yacy/data/wiki/WikiCode.java
@@ -1024,6 +1024,11 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
}
+ /**
+ * Process line with geo coordinate metadata
+ * @param line of wiki text
+ * @return line with geo coordinate formatted to be recogizeable by parser
+ */
private static String processMetadata(String line) {
int p, q, s = 0;
while ((p = line.indexOf(WIKI_OPEN_METADATA, s)) >= 0 && (q = line.indexOf(WIKI_CLOSE_METADATA, p + 1)) >= 0) {
@@ -1041,7 +1046,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
// {{Coordinate |NS 45/37/43.0/N |EW. 07/58/41.0/E |type=landmark |region=IT-BI}} ## means: degree/minute/second
// {{Coordinate |NS 51.48994 |EW. 7.33249 |type=landmark |region=DE-NW}}
final String b[] = a.split("\\|");
- float lon = 0.0f, lat = 0.0f;
+ float lon = Float.NaN, lat = Float.NaN;
float lonm = 0.0f, latm = 0.0f;
String lono = "E", lato = "N";
String name = "";
@@ -1053,18 +1058,18 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
final String d[] = c.substring(3).split("/");
if (d.length == 1) {float l = Float.parseFloat(d[0]); if (l < 0) {lato = "S"; l = -l;} lat = (float) Math.floor(l); latm = 60.0f * (l - lat);}
else if (d.length == 2) {lat = Float.parseFloat(d[0]); latm = Float.parseFloat(d[1]);}
- else if (d.length == 3) {lat = Float.parseFloat(d[0]); latm = Float.parseFloat(d[1]) + Float.parseFloat(d[2]) / 60.0f;}
- if (d[d.length-1].toUpperCase().equals("S")) {}
+ else if (d.length >= 3) {lat = Float.parseFloat(d[0]); latm = Float.parseFloat(d[1]) + Float.parseFloat(d[2]) / 60.0f;}
+ if (d[d.length-1].toUpperCase().equals("S")) {lato = "S";}
}
if (c.toUpperCase().startsWith("EW=")) {
final String d[] = c.substring(3).split("/");
if (d.length == 1) {float l = Float.parseFloat(d[0]); if (l < 0) {lono = "W"; l = -l;} lon = (float) Math.floor(l); lonm = 60.0f * (l - lon);}
else if (d.length == 2) {lon = Float.parseFloat(d[0]); lonm = Float.parseFloat(d[1]);}
- else if (d.length == 3) {lon = Float.parseFloat(d[0]); lonm = Float.parseFloat(d[1]) + Float.parseFloat(d[2]) / 60.0f;}
- if (d[d.length-1].toUpperCase().equals("W")) {lon = -lon; lonm = -lonm;}
+ else if (d.length >= 3) {lon = Float.parseFloat(d[0]); lonm = Float.parseFloat(d[1]) + Float.parseFloat(d[2]) / 60.0f;}
+ if (d[d.length-1].toUpperCase().equals("W")) {lato = "W";}
}
}
- if (lon != 0.0d && lat != 0.0d) {
+ if (!Float.isNaN(lon) && !Float.isNaN(lat)) {
// replace this with a format that the html parser can understand
line = line.substring(0, p) + (name.length() > 0 ? (" " + name) : "") + " " + lato + " " + lat + "\u00B0 " + latm + "'" + lono + " " + lon + "\u00B0 " + lonm + "' " + line.substring(q + WIKI_CLOSE_METADATA.length());
s = p;
diff --git a/test/net/yacy/data/wiki/WikiCodeTest.java b/test/net/yacy/data/wiki/WikiCodeTest.java
new file mode 100644
index 000000000..c4b75a511
--- /dev/null
+++ b/test/net/yacy/data/wiki/WikiCodeTest.java
@@ -0,0 +1,35 @@
+package net.yacy.data.wiki;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+
+public class WikiCodeTest {
+
+ /**
+ * test geo location metadata convert
+ */
+ @Test
+ public void testProcessMetadata() {
+ String[] testmeta = new String[]{
+ "{{coordinate|NS=52.205944|EW=0.117593|region=GB-CAM|type=landmark}}", // decimal N-E location
+ "{{coordinate|NS=43/50/29/N|EW=73/23/17/W|type=landmark|region=US-NY}}", // N-W location
+
+ "{{Coordinate |text=DMS |NS=50/7/49/N |EW=6/8/09/E |type=landmark |region=BE-WLG |name=Monument des trois Frontières}}",
+ "{{Coordinate |text=DMS |NS= 49.047169|EW=7.899148|region=DE-RP |type=landmark |name=Europadenkmal (Rheinland-Pfalz)}}",
+
+ "{{coordinate|NS=0.00000|EW=0.117593}}", // testing equator coord
+ "{{coordinate|NS=-10.00000|EW=-10.10000}}" // testing S-E location
+
+ };
+ WikiCode wc = new WikiCode();
+ for (int i = 0; i < testmeta.length; i++) {
+ String result = wc.transform("http://wiki:8080",testmeta[i]);
+ System.out.println(testmeta[i] + " --> " + result);
+ // simply check if replacement took place, if no coordinate recognized original string is just html encoded
+ assertFalse(result.contains("#124;")); // simple check - result not containing char code for "{",
+ assertFalse(result.contains("#125;")); // simple check - result not containing char code for "}"
+ }
+ }
+
+}
\ No newline at end of file