Ahoj!
> Committed revision 11336.
>
> k nalezeni:
> http://svn.openstreetmap.org/misc/pr_material/czech_poster_2008_10/
Zajimave, jak se ziskavaji commitovaci prava? Mel bych update knihovny
aby chodila s novym API a nameit programek...
Pavel
Index: applications/lib/libosm/Way.cpp
===================================================================
--- applications/lib/libosm/Way.cpp (revision 10789)
+++ applications/lib/libosm/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: applications/lib/libosm/Way.h
===================================================================
--- applications/lib/libosm/Way.h (revision 10789)
+++ applications/lib/libosm/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: applications/lib/libosm/Components.cpp
===================================================================
--- applications/lib/libosm/Components.cpp (revision 10789)
+++ applications/lib/libosm/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: applications/lib/libosm/Parser.cpp
===================================================================
--- applications/lib/libosm/Parser.cpp (revision 10789)
+++ 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 10789)
+++ 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::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
[email protected]
http://lists.openstreetmap.org/listinfo/talk-cz