- show location name in geolocalization search result

- added link from location icon to openstreetmap browser with coordinates

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6305 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 573d03c7d7
commit a58d9cae7d

@ -140,8 +140,8 @@ document.getElementById("Enter").value = "search again";
<a href="/osm.png?lon=#[lon]#&lat=#[lat]#&zoom=14" class="thumblink" style="float:left;" onclick="return hs.expand(this)">
<img src="/osm.png?lon=#[lon]#&lat=#[lat]#&zoom=14" width="192" height="192">
</a>
<div class="highslide-caption">lat=#[lat]#, lon=#[lon]#</div>
<div class="TableCellDark">lat=#[lat]#,<br />lon=#[lon]#</div>
<div class="TableCellDark"><a href="http://www.openstreetmap.org/?lat=#[lat]#&lon=#[lon]#&zoom=14">#[name]#</a><br /><a href="http://www.openstreetmap.org/?lat=#[lat]#&lon=#[lon]#&zoom=14">lat=#[lat]#, lon=#[lon]#</a></div> <!-- preview -->
<div class="highslide-caption"><a href="http://www.openstreetmap.org/?lat=#[lat]#&lon=#[lon]#&zoom=14">#[name]#</a><br /><a href="http://www.openstreetmap.org/?lat=#[lat]#&lon=#[lon]#&zoom=14">lat=#[lat]#, lon=#[lon]#</a></div> <!-- zoomed -->
</div>
#{/loc}#
</p>

@ -35,9 +35,9 @@ import java.util.TreeSet;
import de.anomic.content.RSSMessage;
import de.anomic.crawler.retrieval.LoaderDispatcher;
import de.anomic.data.Coordinates;
import de.anomic.data.DidYouMean;
import de.anomic.data.LibraryProvider;
import de.anomic.data.Location;
import de.anomic.document.Condenser;
import de.anomic.document.Word;
import de.anomic.document.Document;
@ -520,14 +520,15 @@ public class yacysearch {
}
// find geographic info
Set<Coordinates> coordinates = LibraryProvider.geoDB.find(originalquerystring);
Set<Location> coordinates = LibraryProvider.geoDB.find(originalquerystring);
if (coordinates == null || coordinates.size() == 0 || offset > 0) {
prop.put("geoinfo", "0");
} else {
int i = 0;
for (Coordinates c: coordinates) {
for (Location c: coordinates) {
prop.put("geoinfo_loc_" + i + "_lon", Math.round(c.lon() * 10000.0) / 10000.0);
prop.put("geoinfo_loc_" + i + "_lat", Math.round(c.lat() * 10000.0) / 10000.0);
prop.put("geoinfo_loc_" + i + "_name", c.getName());
i++;
if (i >= 5) break;
}

@ -0,0 +1,51 @@
// Coordinates.java
// (C) 2009 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 08.10.2009 on http://yacy.net
//
// This is a part of YaCy
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package de.anomic.data;
public class Location extends Coordinates {
private String name;
public Location(double lon, double lat) {
super(lon, lat);
this.name = null;
}
public Location(double lon, double lat, String name) {
super(lon, lat);
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}

@ -66,7 +66,7 @@ public class OpenGeoDB {
}
private HashMap<Integer, String> locTypeHash2locType;
private HashMap<Integer, Coordinates> id2coord;
private HashMap<Integer, Location> id2loc;
private HashMap<Integer, Integer> id2locTypeHash;
private TreeMap<String, List<Integer>> locationName2ids;
private TreeMap<String, List<Integer>> kfz2ids;
@ -76,7 +76,7 @@ public class OpenGeoDB {
public OpenGeoDB(final File file) {
this.locTypeHash2locType = new HashMap<Integer, String>();
this.id2coord = new HashMap<Integer, Coordinates>();
this.id2loc = new HashMap<Integer, Location>();
this.id2locTypeHash = new HashMap<Integer, Integer>();
this.locationName2ids = new TreeMap<String, List<Integer>>(insensitiveCollator);
this.kfz2ids = new TreeMap<String, List<Integer>>(insensitiveCollator);
@ -104,7 +104,7 @@ public class OpenGeoDB {
if (line.startsWith("geodb_coordinates ")) {
line = line.substring(18 + 7);v = line.split(",");
v = line.split(",");
id2coord.put(Integer.parseInt(v[0]), new Coordinates(Double.parseDouble(v[2]), Double.parseDouble(v[3])));
id2loc.put(Integer.parseInt(v[0]), new Location(Double.parseDouble(v[2]), Double.parseDouble(v[3])));
}
if (line.startsWith("geodb_textdata ")) {
line = line.substring(15 + 7);
@ -116,6 +116,8 @@ public class OpenGeoDB {
if (l == null) l = new ArrayList<Integer>(1);
l.add(id);
this.locationName2ids.put(h, l);
Location loc = this.id2loc.get(id);
if (loc != null) loc.setName(h);
} else if (v[1].equals("500400000")) { // Vorwahl
id = Integer.parseInt(v[0]);
h = removeQuotes(v[2]);
@ -168,7 +170,7 @@ public class OpenGeoDB {
* @param anyname
* @return
*/
public HashSet<Coordinates> find(String anyname) {
public HashSet<Location> find(String anyname) {
HashSet<Integer> r = new HashSet<Integer>();
SortedMap<String, List<Integer>> cities = this.locationName2ids.tailMap(anyname);
for (Map.Entry<String, List<Integer>> e: cities.entrySet()) {
@ -178,9 +180,9 @@ public class OpenGeoDB {
c = this.kfz2ids.get(anyname); if (c != null) r.addAll(c);
c = this.predial2ids.get(anyname); if (c != null) r.addAll(c);
Integer i = this.zip2id.get(anyname); if (i != null) r.add(i);
HashSet<Coordinates> a = new HashSet<Coordinates>();
HashSet<Location> a = new HashSet<Location>();
for (Integer e: r) {
Coordinates w = this.id2coord.get(e);
Location w = this.id2loc.get(e);
if (w != null) a.add(w);
}
return a;

Loading…
Cancel
Save