Ahoj!

> > > Za pomoci sileneho tagovaciho skriptu (a pak rucni kontroly/editace v
> > > emacsu) jsem opravil cestinu ve jmenech ulic v centru prahy -- PSC
> > > 110XX. To co se lisilo jen ve zkratkach nebo velikosti pismen jsem
> > > nechaval na pokoji, ale mozna by stalo zato opravit i to podle
> > > oficialnich dat.
> > 
> > No, a kdyz uz jsem mel po ruce ten sileny skript, tak jsem v centru
> > doplnil chybejici jmena ulic. Ze 71 highway=residential se podarilo
> > najit jmeno pro 57.
> 
> Když jsem se na to díval, připadá mi jako velký problém, že ulice v této
> oblasti byla síť ulic kreslena bez ohledu na jejich pojmenování.
> 
> Například:
> 
> Část ulice "Husova" byla pojmenována již dříve jako "Na Perstyne".
> Nyní byla upravena??? na "Na Perštýně". Skript ovšem neřešil, že ulice "Na
> Perštýně" je výrazně kratší.
> 
> "Retezova" byla správně přejmenována na "Řetězová", nicméně přes ulici
> již zůstal název ???"Retezova" (Jsem přesvědčen, že tam ve skutečnosti
> žádná ulice není, tak jsem jí smazal všechny tagy. Až to někdo ověří,
> tak se buď doplní správně anebo se smaže úplně.)
> 
> Nemáš někde seznam podobných konfliktů? Mohl bys totéž zkusit i na
> Prahu 2, kde jsem se pokoušel podobné problémy likvidovat ručně (na
> 12800).
> 
> 
> Možná by šlo přidat pravidlo:
> Na mapě se ulice jmenuje A. V UIR-ADR se jmenuje B. V UIR-ADR existuje A
> i B => rozděl ulici.

Muzes zkusit ;-). Ale zas _tak_ dobra ta statistika neni.

(Jinak 12800 jsem projel, viz jiny mail, vysledek by mel byt v
databazi).

                                                                        Pavel

Index: Way.cpp
===================================================================
--- Way.cpp     (revision 10302)
+++ Way.cpp     (working copy)
@@ -63,9 +63,12 @@
 {
 
        if (hasTags() || segments.size()) {
-               strm << "  <way id='" << id << "'>" << endl;
+               strm << "  <way id='" << id << "'";
+               if (changed)
+                       strm << " action='modify'";
+               strm << ">" << endl;
                for(int count=0; count<segments.size(); count++)
-                       strm  << "    <seg id='" << segments[count] << "'/>" << 
endl;
+                       strm  << "    <nd ref='" << segments[count] << "'/>" << 
endl;
                tagsToXML(strm);
                strm << "  </way>" << endl;
        } else {
Index: Way.h
===================================================================
--- Way.h       (revision 10302)
+++ Way.h       (working copy)
@@ -38,14 +38,18 @@
        vector<int> segments;
 
 public:
+       int changed;
+
        Way()
        {
                id = 0;
+               changed = 0;
        }
 
        Way(int id)
        {
                this->id=id;
+               changed = 0;
        }
 
        void addSegment (int s)
Index: Components.cpp
===================================================================
--- Components.cpp      (revision 10302)
+++ Components.cpp      (working copy)
@@ -17,7 +17,6 @@
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
 
  */
-// 180306 updated for 0.3    
 #include "Components.h"
 #include <iostream>
 #include <fstream>
@@ -355,7 +354,7 @@
 
 void Components::toXML(std::ostream &strm)
 {
-       strm << "<?xml version='1.0'?>"<<endl<<"<osm version='0.3'>" << endl;
+       strm << "<?xml version='1.0'?>"<<endl<<"<osm version='0.5'>" << endl;
        rewindNodes();
        while(hasMoreNodes())
        {
Index: Parser.cpp
===================================================================
--- Parser.cpp  (revision 10302)
+++ Parser.cpp  (working copy)
@@ -45,23 +45,6 @@
                        
 
                }
-               else if(!strcmp(element,"segment"))
-               {
-                       curID=0;
-                       inSegment = true;
-                       for(int count=0; attrs[count]; count+=2)
-                       {
-                               if(!strcmp(attrs[count],"from"))
-                                       from = atoi(attrs[count+1]);
-                               if(!strcmp(attrs[count],"to"))
-                                       to = atoi(attrs[count+1]);
-                               if(!strcmp(attrs[count],"id"))
-                                       curID = atoi(attrs[count+1]);
-                       }
-
-                       curObject = new Segment(curID,from,to);
-                       components->addSegment ((Segment*)curObject);
-               }
                else if (!strcmp(element,"way"))
                {
                        curID=0;
@@ -74,13 +57,13 @@
                        curObject  =  new Way(curID);
                        components->addWay((Way*)curObject);
                }
-               else if (!strcmp(element,"seg") && (inWay))
+               else if (!strcmp(element,"nd") && (inWay))
                {
                        int segID;
 
                        for(int count=0; attrs[count]; count+=2)
                        {
-                               if(!strcmp(attrs[count],"id"))
+                               if(!strcmp(attrs[count],"ref"))
                                {
                                        segID=atoi(attrs[count+1]);
                                        ((Way*)curObject)->addSegment(segID);
Index: Makefile
===================================================================
--- Makefile    (revision 10302)
+++ Makefile    (working copy)
@@ -3,6 +3,7 @@
 OBJ = Object.o Way.o Parser.o Components.o functions.o llgr.o FeaturesParser.o
 NETOBJ = Client.o
 TESTOBJ = test.o
+NAMEITOBJ = nameit.o
 RULESTESTOBJ = rulestest.o
 CXX = g++
 
@@ -15,6 +16,9 @@
 test: $(TESTOBJ) libosm.a libosmnet.a
        $(CXX) -o test $(TESTOBJ) libosm.a libosmnet.a $(LDFLAGS)
 
+nameit: $(NAMEITOBJ) libosm.a libosmnet.a
+       $(CXX) -o nameit $(NAMEITOBJ) libosm.a libosmnet.a $(LDFLAGS)
+
 rulestest: $(RULESTESTOBJ) libosm.a 
        $(CXX) -o rulestest $(RULESTESTOBJ) libosm.a $(LDFLAGS)
 


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#include "Parser.h"
#include "Client.h"
#include "Node.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include "functions.h"

using std::cerr;
using std::cerr;
using std::endl;

void dotest(OSM::Components *comp1);

int main(int argc,char* argv[])
{
	if(argc<1)
	{
		cerr<<"Usage: test InOsmFile OsmUsername OsmPassword" << endl;
		exit(1);
	}
	
	std::ifstream in(argv[1]);
	OSM::Components *comp1 = OSM::Parser::parse(in);
	in.close();

	cerr << "Testing components from local file:" << endl;
	dotest(comp1);

	comp1->toXML(std::cout);

	delete comp1;

	return 0;

}

struct ltstr
{
  bool operator()(const std::string s1, const std::string s2) const
  {
    return s1 < s2;
  }
};


void
oneaddress(OSM::Way *w, OSM::Node *n1, OSM::Node *n2, OSM::Node *n,  std::map <std::string, float> &results)
{
	std::vector<std::string> keys = n->getTags();
	const std::string street = n->tags["addr:street"];

	if (street == "")
		return;

	float dist = OSM::distp(n->getLat(), n->getLon(), 
				n1->getLat(), n1->getLon(), 
				n2->getLat(), n2->getLon());

	if (dist < 0.0005) {
	  // cerr << "Have street " << street << " near way is " << w->tags["name"] << endl;
	  	results[street] += 1/(dist+.00001);
	}

}

static int total_ways, processed_ways, 
  	   test_total, test_okay, test_coverage, devel_total, devel_coverage;

void dotest(OSM::Components *comp1)
{
	comp1->rewindSegments();
	comp1->rewindWays();

	while(comp1->hasMoreWays())
	{
		OSM::Way *w = comp1->nextWay();
		//		cerr << "Way id: " << w->id << " tags:" << endl;

		std::vector<std::string> keys = w->getTags();
		OSM::Node *n1 = NULL, *n2 = NULL;
		std::map <std::string, float> results;

		total_ways++;

		if (w->tags["highway"] != "residential")
		  continue;
		
		processed_ways++;
#if 0
		for(int count=0; count<keys.size(); count++)
		{
		  	cerr  << "Key: " << keys[count] << " Value: " << 
				w->tags[keys[count]] << endl;
		}
#endif
		for(int count=0; count<w->nSegments(); count++)
		{
		  //			cerr  << "Node: " << w->getSegment(count) << endl;

			n2 = n1;
			n1 = comp1->getNode(w->getSegment(count));

			if (n2)
			{
				comp1->rewindNodes();
				while(comp1->hasMoreNodes())
				{
					OSM::Node *n = comp1->nextNode();
					oneaddress(w, n1, n2, n, results);
				}
			}

		}

		float max = 0; std::string maxs = "";

		cerr << w->id << " " << w->tags["name"];
		//		cerr << endl << "-------------------" << endl;
		for(std::map<std::string,float>::iterator i=results.begin(); 
		    i!=results.end(); i++) {
		  //		  	cerr << i->first << " - " << i->second << endl;
			if (i->second > max) {
				max = i->second;
				maxs = i->first;
			}
		}
		cerr << " : " << maxs << endl;
		if (w->tags["name"] != "") {
		  test_total++;
		  if (maxs != "") {
		    test_coverage++;
		    if (maxs == w->tags["name"])
		      test_okay++;
		    else {
		      w->tags["autoname"] = maxs;
		      w->tags["autoname:source"] = "nameit/uir-adr";
		    }
		  }
		} else {
		  devel_total++;
		  if (maxs != "") {
		    devel_coverage++;
		    w->tags["name"] = maxs;
		    w->tags["name:source"] = "nameit/uir-adr";
		    w->changed = 1;
		  }
		}
	}
	fprintf(stderr, "-------------------------------------------------------\n");
	fprintf(stderr, "%d total ways, %d processed\n", total_ways, processed_ways);
	fprintf(stderr, "... test total %d ways, coverage %d, okay %d (precission %d%%, recall %d%%)\n", test_total, test_coverage, test_okay, (int) ((test_okay*100.0) / test_coverage),  (int) ((test_coverage*100.0) / test_total));
	fprintf(stderr, "... devel total %d ways, coverage %d, okay ??? (precission ???, recall %d%%)\n", devel_total, devel_coverage, (int) ((devel_coverage*100.0) / devel_total));
}
_______________________________________________
Talk-cz mailing list
Talk-cz@openstreetmap.org
http://lists.openstreetmap.org/listinfo/talk-cz

Odpovedet emailem