...docela funguje, tj "na uz pojmenovanych ulicich se vetsinou
trefi". Prvni verse je tady.

(Samozrejme ocekava uid-adr adresni body jiz importovane... Coz se da
pro lokalni pouziti udelat treba tou shellovou priserou, pak download
zbytku v josm a ulozenim.)

Index: applications/lib/libosm/Way.cpp
===================================================================
--- applications/lib/libosm/Way.cpp     (revision 10302)
+++ applications/lib/libosm/Way.cpp     (working copy)
@@ -65,7 +65,7 @@
        if (hasTags() || segments.size()) {
                strm << "  <way id='" << id << "'>" << endl;
                for(int count=0; count<segments.size(); count++)
-                       strm  << "    <seg id='" << segments[count] << "'/>" << 
endl;
+                       strm  << "    <nd id='" << segments[count] << "'/>" << 
endl;
                tagsToXML(strm);
                strm << "  </way>" << endl;
        } else {
Index: applications/lib/libosm/Parser.cpp
===================================================================
--- applications/lib/libosm/Parser.cpp  (revision 10302)
+++ applications/lib/libosm/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: applications/lib/libosm/Makefile
===================================================================
--- applications/lib/libosm/Makefile    (revision 10302)
+++ applications/lib/libosm/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::cout;
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();

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

	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.001) {
	  // cout << "Have street " << street << " near way is " << w->tags["name"] << endl;
	  	results[street] += 1/dist;
	}

}


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

	while(comp1->hasMoreWays())
	{
		OSM::Way *w = comp1->nextWay();
		//		cout << "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;

#if 0
		for(int count=0; count<keys.size(); count++)
		{
		  	cout  << "Key: " << keys[count] << " Value: " << 
				w->tags[keys[count]] << endl;
		}
#endif
		for(int count=0; count<w->nSegments(); count++)
		{
		  //			cout  << "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 = "";

		cout << w->id << " " << w->tags["name"];
		//		cout << endl << "-------------------" << endl;
		for(std::map<std::string,float>::iterator i=results.begin(); 
		    i!=results.end(); i++) {
		  //		  	cout << i->first << " - " << i->second << endl;
			if (i->second > max) {
				max = i->second;
				maxs = i->first;
			}
		}
		cout << " : " << maxs << endl;


	}
}
_______________________________________________
Talk-cz mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/talk-cz

Odpovedet emailem