Index: /applications/editors/josm/plugins/pointInfo/build.xml
===================================================================
--- /applications/editors/josm/plugins/pointInfo/build.xml	(revision 30465)
+++ /applications/editors/josm/plugins/pointInfo/build.xml	(revision 30466)
@@ -3,5 +3,5 @@
 
     <!-- enter the SVN commit message -->
-    <property name="commit.message" value="PointInfo: Add more external links, nicer icons."/>
+    <property name="commit.message" value="PointInfo: Add support for ghost buildings."/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
     <property name="plugin.main.version" value="7001"/>
Index: /applications/editors/josm/plugins/pointInfo/po/cs.po
===================================================================
--- /applications/editors/josm/plugins/pointInfo/po/cs.po	(revision 30465)
+++ /applications/editors/josm/plugins/pointInfo/po/cs.po	(revision 30466)
@@ -7,5 +7,5 @@
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-03-19 20:18+0100\n"
+"POT-Creation-Date: 2014-05-14 20:25+0200\n"
 "PO-Revision-Date: 2014-02-09 22:48+0100\n"
 "Last-Translator: Marian Kyral <mkyral@email.cz>\n"
@@ -18,38 +18,38 @@
 "X-Generator: Lokalize 1.5\n"
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:71
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:74
 msgid "Point info"
 msgstr "Informace o bodu"
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:71
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:74
 msgid "Point info."
 msgstr "Informace o bodu."
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:71
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:74
 #, java-format
 msgid "Tool: {0}"
 msgstr "Nástroje: {0}"
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:118
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:107
 msgid "Connecting server"
 msgstr "Připojuji se na server"
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:156
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:148
+msgid "Data not available."
+msgstr "Data nejsou dostupná."
+
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:249
 msgid "PointInfo"
 msgstr "Informace o bodu"
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:185
-msgid "Data not available."
-msgstr "Data nejsou dostupná."
-
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:835
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:1088
 msgid "Add new address point"
 msgstr "Přidán nový adresní bod"
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:857
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:1110
 msgid "Tags copied to clipboard."
 msgstr "Tagy byly zkopírovány do schránky."
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:865
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:1118
 msgid "New address point added."
 msgstr "Adresní bod byl přidán."
Index: /applications/editors/josm/plugins/pointInfo/po/pointInfo.po
===================================================================
--- /applications/editors/josm/plugins/pointInfo/po/pointInfo.po	(revision 30465)
+++ /applications/editors/josm/plugins/pointInfo/po/pointInfo.po	(revision 30466)
@@ -9,5 +9,5 @@
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-03-19 20:18+0100\n"
+"POT-Creation-Date: 2014-05-20 07:17+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
@@ -18,38 +18,38 @@
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:71
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:74
 msgid "Point info"
 msgstr ""
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:71
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:74
 msgid "Point info."
 msgstr ""
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:71
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:74
 #, java-format
 msgid "Tool: {0}"
 msgstr ""
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:118
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:107
 msgid "Connecting server"
 msgstr ""
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:156
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:148
+msgid "Data not available."
+msgstr ""
+
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:249
 msgid "PointInfo"
 msgstr ""
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java:185
-msgid "Data not available."
-msgstr ""
-
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:835
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:1088
 msgid "Add new address point"
 msgstr ""
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:857
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:1110
 msgid "Tags copied to clipboard."
 msgstr ""
 
-#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:865
+#: ../src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java:1118
 msgid "New address point added."
 msgstr ""
Index: /applications/editors/josm/plugins/pointInfo/servers/RUIAN/index.php
===================================================================
--- /applications/editors/josm/plugins/pointInfo/servers/RUIAN/index.php	(revision 30465)
+++ /applications/editors/josm/plugins/pointInfo/servers/RUIAN/index.php	(revision 30466)
@@ -4,4 +4,36 @@
 $lon=$_REQUEST['lon'];
 if ( !is_numeric($lat) or !is_numeric($lon) ) die;
+
+
+// From:   http://www.sitepoint.com/forums/showthread.php?656315-Adding-Distance-To-GPS-Coordinates-To-Get-Bounding-Box&p=4519646&viewfull=1#post4519646
+function new_coords($lat, $lon, $bearing, $distance)
+{
+  // Radius of Earth in meters
+  $radius = 6371000;
+
+  //  New latitude in degrees.
+  $new_lat = rad2deg(asin(sin(deg2rad($lat)) * cos($distance / $radius) + cos(deg2rad($lat)) * sin($distance / $radius) * cos(deg2rad($bearing))));
+
+  //  New longitude in degrees.
+  $new_lon = rad2deg(deg2rad($lon) + atan2(sin(deg2rad($bearing)) * sin($distance / $radius) * cos(deg2rad($lat)), cos($distance / $radius) - sin(deg2rad($lat)) * sin(deg2rad($new_lat))));
+
+  //  Assign new latitude and longitude to an array to be returned to the caller.
+  $coord['lat'] = $new_lat;
+  $coord['lon'] = $new_lon;
+
+  return $coord;
+}
+
+// Boundary box 20x20 meters around the point
+$x1_coor = new_coords($lat, $lon, 315, 10); // Left upper point
+$x2_coor = new_coords($lat, $lon, 135, 10); // Right down point
+
+$x1_lon = $x1_coor['lon'];
+$x2_lon = $x2_coor['lon'];
+$x1_lat = $x1_coor['lat'];
+$x2_lat = $x2_coor['lat'];;
+
+$boundary_polygon=($x1_lon) . " " . ($x1_lat) . ", " . ($x1_lon) . " " . ($x2_lat) . ", " . ($x2_lon) . " " . ($x2_lat) . ", " . ($x2_lon) . " " . ($x1_lat) . ", " . ($x1_lon) . " " . ($x1_lat);
+
 header('Content-Type: application/json');
 
@@ -43,4 +75,48 @@
 } else
     $data["stavebni_objekt"] = array();
+
+// Ghosts: Buildings without geometry in close neighbourhood
+$query="
+select * from (
+  select s.kod,
+        s.pocet_podlazi, a.nazev zpusob_vyuziti, s.plati_od, s.pocet_bytu, s.dokonceni,
+        s.zpusob_vyuziti_kod, a.osmtag_k, a.osmtag_v,
+        s.definicni_bod,
+        st_distance( (st_transform(s.definicni_bod,4326))::geography, (st_setsrid(st_makepoint(".$lon.",".$lat."),4326))::geography ) dist
+  from rn_stavebni_objekt s
+      left outer join osmtables.zpusob_vyuziti_objektu a on s.zpusob_vyuziti_kod = a.kod
+  where st_intersects(s.definicni_bod, st_transform(st_geometryfromtext(
+      'POLYGON (( $boundary_polygon ))' ,4326),900913))
+    and not s.deleted
+    and s.hranice is null
+    order by definicni_bod <->
+          st_transform(st_setsrid(st_makepoint(".$lon.",".$lat."),4326),900913)
+  limit 5) as x
+  order by dist;
+";
+$result=pg_query($CONNECT,$query);
+
+if (pg_num_rows($result) > 0)
+{
+    $so = array();
+    for ($i = 0; $i < pg_num_rows($result); $i++)
+    {
+      $row = pg_fetch_array($result, $i);
+      array_push($so,
+                  array( "ruian_id" => $row["kod"],
+                         "pocet_podlazi" => $row["pocet_podlazi"],
+                         "zpusob_vyuziti" => $row["zpusob_vyuziti"],
+                         "zpusob_vyuziti_kod" => $row["zpusob_vyuziti_kod"],
+                         "zpusob_vyuziti_key" => $row["osmtag_k"],
+                         "zpusob_vyuziti_val" => $row["osmtag_v"],
+                         "pocet_bytu" => $row["pocet_bytu"],
+                         "dokonceni" => $row["dokonceni"],
+                         "plati_od" => $row["plati_od"],
+                         "vzdalenost" => $row["dist"]
+                        ));
+    }
+      $data["so_bez_geometrie"] = $so;
+} else
+    $data["so_bez_geometrie"] = array();
 
 // Addresses
@@ -136,5 +212,6 @@
          am.adrp_psc psc, ul.nazev ulice, c.nazev cast_obce,
          momc.nazev mestska_cast,
-         ob.nazev obec, ok.nazev okres, vu.nazev kraj
+         ob.nazev obec, ok.nazev okres, vu.nazev kraj,
+         st_distance( (st_transform(am.definicni_bod,4326))::geography, (st_setsrid(st_makepoint(".$lon.", ".$lat."),4326))::geography ) dist
   from ( select kod, stavobj_kod,
                 cislo_domovni, cislo_orientacni_hodnota, cislo_orientacni_pismeno,
@@ -155,6 +232,5 @@
       left outer join rn_vusc vu on ok.vusc_kod = vu.kod and not vu.deleted
   where st_distance( (st_transform(am.definicni_bod,4326))::geography, (st_setsrid(st_makepoint(".$lon.", ".$lat."),4326))::geography ) < 100
-  order by st_distance( (st_transform(am.definicni_bod,4326))::geography,
-                        (st_setsrid(st_makepoint(".$lon.", ".$lat."),4326))::geography)
+  order by dist
   limit 5
   ;
@@ -183,5 +259,6 @@
                         "okres" => $row["okres"],
                         "kraj" => $row["kraj"],
-                        "psc" => $row["psc"]
+                        "psc" => $row["psc"],
+                        "vzdalenost" => $row["dist"]
                         ));
     }
Index: /applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java
===================================================================
--- /applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java	(revision 30465)
+++ /applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java	(revision 30466)
@@ -103,5 +103,5 @@
                 @Override
                 protected void realRun() throws SAXException {
-                    infoSync(pos, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
+                    infoSync(pos, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, true));
                 }
 
Index: /applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java
===================================================================
--- /applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java	(revision 30465)
+++ /applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruianModule.java	(revision 30466)
@@ -37,4 +37,7 @@
 import java.io.InputStream;
 import java.io.ByteArrayInputStream;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
 
 import javax.json.Json;
@@ -74,4 +77,5 @@
     private String  m_kraj;
     private String  m_psc;
+    private float   m_vzdalenost;
 
     public addrPlaces () {
@@ -99,4 +103,5 @@
       m_kraj = "";
       m_psc = "";
+      m_vzdalenost = 0;
     }
 
@@ -177,4 +182,8 @@
     }
 
+    public void setVzdalenost (float v) {
+      m_vzdalenost = v;
+    }
+
     public long getRuianID () {
       return m_ruian_id;
@@ -253,4 +262,120 @@
     }
 
+    public String getVzdalenost () {
+      DecimalFormat df = new DecimalFormat("0.00");
+      return df.format(m_vzdalenost) + "m";
+    }
+
+}
+
+class objectWithoutGeometry {
+    private long     m_ruian_id;
+    private int      m_podlazi;
+    private int      m_byty;
+    private String   m_zpusob_vyuziti;
+    private String   m_zpusob_vyuziti_kod;
+    private String   m_zpusob_vyuziti_key;
+    private String   m_zpusob_vyuziti_val;
+    private String   m_dokonceni;
+    private String   m_plati_od;
+    private float    m_vzdalenost;
+
+    public objectWithoutGeometry () {
+      init();
+    }
+
+    private void init () {
+      m_ruian_id = 0;
+      m_podlazi = 0;
+      m_byty = 0;
+      m_zpusob_vyuziti = "";
+      m_zpusob_vyuziti_kod = "";
+      m_zpusob_vyuziti_key = "";
+      m_zpusob_vyuziti_val = "";
+      m_dokonceni = "";
+      m_plati_od = "";
+      m_vzdalenost = 0;
+    }
+
+    public void setRuianID (long v) {
+      m_ruian_id = v;
+    }
+
+    public void setPodlazi (int v) {
+      m_podlazi = v;
+    }
+
+    public void setByty (int v) {
+      m_byty = v;
+    }
+
+    public void setZpusobVyuziti (String v) {
+      m_zpusob_vyuziti = v;
+    }
+
+    public void setZpusobVyuzitiKod (String v) {
+      m_zpusob_vyuziti_kod = v;
+    }
+
+    public void setZpusobVyuzitiKey (String v) {
+      m_zpusob_vyuziti_key = v;
+    }
+
+    public void setZpusobVyuzitiVal (String v) {
+      m_zpusob_vyuziti_val = v;
+    }
+
+    public void setDokonceni (String v) {
+      m_dokonceni = v;
+    }
+
+    public void setPlatiOd (String v) {
+      m_plati_od = v;
+    }
+
+    public void setVzdalenost (float v) {
+      m_vzdalenost = v;
+    }
+
+    public long getRuianID () {
+      return m_ruian_id;
+    }
+
+    public int getPodlazi () {
+      return m_podlazi;
+    }
+
+    public int getByty () {
+      return m_byty;
+    }
+
+    public String getZpusobVyuziti () {
+      return m_zpusob_vyuziti;
+    }
+
+    public String getZpusobVyuzitiKod () {
+      return m_zpusob_vyuziti_kod;
+    }
+
+    public String getZpusobVyuzitiKey () {
+      return m_zpusob_vyuziti_key;
+    }
+
+    public String getZpusobVyuzitiVal () {
+      return m_zpusob_vyuziti_val;
+    }
+
+    public String getDokonceni () {
+      return m_dokonceni;
+    }
+
+    public String getPlatiOd () {
+      return m_plati_od;
+    }
+
+    public String getVzdalenost () {
+      DecimalFormat df = new DecimalFormat("0.00");
+      return df.format(m_vzdalenost) + "m";
+    }
 }
 
@@ -275,4 +400,6 @@
     private String   m_objekt_plati_od;
 
+    private ArrayList <objectWithoutGeometry> m_so_bez_geometrie;
+
     private ArrayList <addrPlaces> m_adresni_mista;
 
@@ -323,4 +450,5 @@
       m_objekt_plati_od = "";
 
+      m_so_bez_geometrie = new ArrayList<objectWithoutGeometry> ();
       m_adresni_mista = new ArrayList<addrPlaces> ();
 
@@ -446,4 +574,79 @@
 // =========================================================================
       try {
+        JsonArray arr = obj.getJsonArray("so_bez_geometrie");
+
+        for(int i = 0; i < arr.size(); i++)
+        {
+          JsonObject soBezGeom = arr.getJsonObject(i);
+          objectWithoutGeometry so = new objectWithoutGeometry();
+
+          try {
+            so.setRuianID(Long.parseLong(soBezGeom.getString("ruian_id")));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.ruian_id: " + e.getMessage());
+          }
+
+          try {
+            so.setPodlazi(Integer.parseInt(soBezGeom.getString("pocet_podlazi")));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.pocet_podlazi: " + e.getMessage());
+          }
+
+          try {
+            so.setByty(Integer.parseInt(soBezGeom.getString("pocet_bytu")));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.pocet_bytu: " + e.getMessage());
+          }
+
+          try {
+            so.setZpusobVyuziti(soBezGeom.getString("zpusob_vyuziti"));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.zpusob_vyuziti: " + e.getMessage());
+          }
+
+          try {
+            so.setZpusobVyuzitiKod(soBezGeom.getString("zpusob_vyuziti_kod"));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.zpusob_vyuziti_kod: " + e.getMessage());
+          }
+
+          try {
+            so.setZpusobVyuzitiKey(soBezGeom.getString("zpusob_vyuziti_key"));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.zpusob_vyuziti_key: " + e.getMessage());
+          }
+
+          try {
+            so.setZpusobVyuzitiVal(soBezGeom.getString("zpusob_vyuziti_val"));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.zpusob_vyuziti_val: " + e.getMessage());
+          }
+
+          try {
+            so.setDokonceni(soBezGeom.getString("dokonceni"));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.dokonceni: " + e.getMessage());
+          }
+
+          try {
+            so.setPlatiOd(soBezGeom.getString("plati_od"));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.plati_od: " + e.getMessage());
+          }
+
+          try {
+            so.setVzdalenost(Float.parseFloat(soBezGeom.getString("vzdalenost")));
+          } catch (Exception e) {
+            System.out.println("so_bez_geometrie.vzdalenost: " + e.getMessage());
+          }
+
+          m_so_bez_geometrie.add(so);
+        }
+      } catch (Exception e) {
+        System.out.println("so_bez_geometrie: " + e.getMessage());
+      }
+
+// =========================================================================
+      try {
         JsonArray arr = obj.getJsonArray("adresni_mista");
 
@@ -569,4 +772,10 @@
           } catch (Exception e) {
             System.out.println("adresni_mista.psc: " + e.getMessage());
+          }
+
+          try {
+            am.setVzdalenost(Float.parseFloat(adresniMisto.getString("vzdalenost")));
+          } catch (Exception e) {
+            System.out.println("adresni_mista.vzdalenost: " + e.getMessage());
           }
 
@@ -879,4 +1088,6 @@
           r.append("<tr><td bgcolor=#e5e5ff>");
           if (!m_adresni_mista.get(i).getUlice().isEmpty()) {
+            r.append(m_adresni_mista.get(i).getVzdalenost());
+            r.append("</td><td valign=\"top\"  bgcolor=#e5e5ff>");
             r.append(m_adresni_mista.get(i).getUlice() + " " + x);
             r.append("<br/><u>" + m_adresni_mista.get(i).getObec() + "</u>");
@@ -887,4 +1098,6 @@
             r.append("&nbsp;&nbsp;<a href=file://tags.create-on-place/address:"+i+">"+ icon_create_addr_ruian +"</a>");
           } else {
+            r.append(m_adresni_mista.get(i).getVzdalenost());
+            r.append("</td><td valign=\"top\"  bgcolor=#e5e5ff>");
             r.append(m_adresni_mista.get(i).getCastObce() + " " + x + "&nbsp;");
             if (!m_adresni_mista.get(i).getCastObce().equals(m_adresni_mista.get(i).getObec())) {
@@ -901,4 +1114,25 @@
         r.append("</table><br/>");
       }
+
+      if (m_so_bez_geometrie.size() > 0) {
+        r.append("<i><u>Budovy bez geometrie v okolí</u></i><br/>");
+        r.append("<table>");
+        for (int i=0; i<m_so_bez_geometrie.size(); i++) {
+          r.append("<tr><td bgcolor=#e5e5ff>");
+          r.append(m_so_bez_geometrie.get(i).getVzdalenost());
+          r.append("</td><td valign=\"top\"  bgcolor=#e5e5ff>");
+          r.append(m_so_bez_geometrie.get(i).getRuianID());
+          if (m_so_bez_geometrie.get(i).getZpusobVyuziti().length() > 0) {
+            r.append(" - " + m_so_bez_geometrie.get(i).getZpusobVyuziti());
+          }
+          r.append("</td><td valign=\"top\"  bgcolor=#e5e5ff>");
+          r.append("&nbsp;&nbsp;<a href="+ url_stavebni_objekt + m_so_bez_geometrie.get(i).getRuianID() + ">"+ icon_ext_link +"</a> ");
+          r.append("&nbsp;&nbsp;<a href=file://tags.copy/building>"+ icon_copy_tags +"</a></br>");
+          r.append("</td></tr>");
+        }
+        r.append("</table><br/>");
+        r.append("<br/>");
+      }
+
       r.append("<hr/>");
       r.append("<center><i><small>Zdroj: <a href=\"http://www.ruian.cz/\">" + m_source + "</a></small></i></center>");
@@ -1130,5 +1364,5 @@
 
     private String m_text = "";
-    private String URL = "http://josm.poloha.net/pointInfo/v2/index.php";
+    private String URL = "http://josm.poloha.net/pointInfo/v3/index.php";
     protected PointInfoServer server = new PointInfoServer();
 
