void runAltFormatTest() { PoiPolygonAddressScoreExtractor uut; uut.setConfiguration(conf()); OsmMapPtr map(new OsmMap()); NodePtr node1(new Node(Status::Unknown1, -1, Coordinate(0.0, 0.0), 15.0)); node1->getTags().set( TestUtils::FULL_ADDRESS_TAG_NAME_2, "Main Street 123 20121 mytown"); map->addNode(node1); WayPtr way1(new Way(Status::Unknown2, -1, 15.0)); way1->getTags().set(TestUtils::FULL_ADDRESS_TAG_NAME_2, "main street 123"); map->addWay(way1); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, uut.extract(*map, node1, way1), 0.0); NodePtr node2(new Node(Status::Unknown1, -2, Coordinate(0.0, 0.0), 15.0)); node2->getTags().set( TestUtils::FULL_ADDRESS_TAG_NAME_2, "Main Street 123 20121 mytown"); map->addNode(node2); WayPtr way2(new Way(Status::Unknown2, -2, 15.0)); way2->getTags().set( TestUtils::FULL_ADDRESS_TAG_NAME_2, "first street 567"); map->addWay(way2); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, uut.extract(*map, node2, way2), 0.01); NodePtr node3(new Node(Status::Unknown1, -1, Coordinate(0.0, 0.0), 15.0)); node3->getTags().set( TestUtils::FULL_ADDRESS_TAG_NAME_2, "ZENTRALLÄNDSTRASSE 40 81379 MÜNCHEN"); map->addNode(node3); WayPtr way3(new Way(Status::Unknown2, -1, 15.0)); way3->getTags().set(TestUtils::FULL_ADDRESS_TAG_NAME_2, "40 ZENTRALLÄNDSTRASSE"); map->addWay(way3); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, uut.extract(*map, node3, way3), 0.0); }
void runRelationTest() { PoiPolygonAddressScoreExtractor uut; uut.setConfiguration(conf()); OsmMapPtr map(new OsmMap()); NodePtr node1(new Node(Status::Unknown1, -1, Coordinate(0.0, 0.0), 15.0)); node1->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123"); node1->getTags().set(TestUtils::STREET_TAG_NAME, "Main Street"); map->addNode(node1); RelationPtr relation1(new Relation(Status::Unknown2, -1, 15.0)); NodePtr node2(new Node(Status::Unknown1, -2, Coordinate(0.0, 0.0), 15.0)); node2->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123"); node2->getTags().set(TestUtils::STREET_TAG_NAME, "main street"); map->addNode(node2); relation1->addElement("test", node2->getElementId()); map->addRelation(relation1); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, uut.extract(*map, node1, relation1), 0.0); NodePtr node4(new Node(Status::Unknown1, -4, Coordinate(0.0, 0.0), 15.0)); node4->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123"); node4->getTags().set(TestUtils::STREET_TAG_NAME, "Main Street"); map->addNode(node4); RelationPtr relation3(new Relation(Status::Unknown2, -3, 15.0)); NodePtr node5(new Node(Status::Unknown1, -5, Coordinate(0.0, 0.0), 15.0)); node5->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "567"); node5->getTags().set(TestUtils::STREET_TAG_NAME, "first street"); map->addNode(node5); relation3->addElement("test", node5->getElementId()); map->addRelation(relation3); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, uut.extract(*map, node4, relation3), 0.01); NodePtr node6(new Node(Status::Unknown1, -6, Coordinate(0.0, 0.0), 15.0)); node6->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "567"); node6->getTags().set(TestUtils::STREET_TAG_NAME, "first street"); map->addNode(node6); RelationPtr relation4(new Relation(Status::Unknown2, -4, 15.0)); WayPtr way3(new Way(Status::Unknown2, -3, 15.0)); way3->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123"); way3->getTags().set(TestUtils::STREET_TAG_NAME, "main street"); map->addWay(way3); relation4->addElement("test", way3->getElementId()); map->addRelation(relation4); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, uut.extract(*map, node6, relation4), 0.01); }
void permunation1_opt2(int n, int * num) { int a = n / 4; int b = n % 4; num[n] = 0; switch (b) { case 0: way4(num, num + 4, num + n); break; case 3: way3(num, num + 3, num + n, num + 3, num + 7, num + n); break; case 2: way2(num, num + 2, num + n, num + 2, num + 6, num + n); break; case 1: way1(num, num + 1, num + n, num + 1, num + 5, num + n); } }
void runRangeTest() { PoiPolygonAddressScoreExtractor uut; uut.setConfiguration(conf()); OsmMapPtr map(new OsmMap()); NodePtr node1(new Node(Status::Unknown1, -1, Coordinate(0.0, 0.0), 15.0)); node1->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123-125"); node1->getTags().set(TestUtils::STREET_TAG_NAME, "Main Street"); map->addNode(node1); WayPtr way1(new Way(Status::Unknown2, -1, 15.0)); way1->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "124"); way1->getTags().set(TestUtils::STREET_TAG_NAME, "main street"); map->addWay(way1); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, uut.extract(*map, node1, way1), 0.0); NodePtr node2(new Node(Status::Unknown1, -2, Coordinate(0.0, 0.0), 15.0)); node2->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123-125"); node2->getTags().set(TestUtils::STREET_TAG_NAME, "Main Street"); map->addNode(node2); WayPtr way2(new Way(Status::Unknown2, -2, 15.0)); way2->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123"); way2->getTags().set(TestUtils::STREET_TAG_NAME, "main street"); map->addWay(way2); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, uut.extract(*map, node2, way2), 0.0); NodePtr node3(new Node(Status::Unknown1, -3, Coordinate(0.0, 0.0), 15.0)); node3->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "123-125"); node3->getTags().set(TestUtils::STREET_TAG_NAME, "Main Street"); map->addNode(node3); WayPtr way3(new Way(Status::Unknown2, -3, 15.0)); way3->getTags().set(TestUtils::HOUSE_NUMBER_TAG_NAME, "567"); way3->getTags().set(TestUtils::STREET_TAG_NAME, "first street"); map->addWay(way3); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, uut.extract(*map, node3, way3), 0.01); }
void way4(int *a, int *b, int *end) { if (b >= end) { generatePermunationHead(num, len); return; } int * a1 = a + 1; int * a2 = a + 2; int * a3 = a + 3; int *end1 = end - 1; way3(a + 1, b, end, b, b + 4, end); int * start = 0; int *p; int *vb = b; int *vbb = b + 4; int *vend = end; while (b < end - 3) { // swap(a, b); //way4(b, b + 4, end); int t1 = *a1, t2 = *a2, t3 = *a3; *a1 = *(b + 1); *a2 = *(b + 2); *a3 = *(b + 3); int *p = b + 4; while (p < end) { *(p - 3) = *p; p++; } *(end - 3) = t1; *(end - 2) = t2; *(end - 1) = t3; way3(a + 1, b + 1, end, vb, vbb, vend); b = b + 1; } swap(a, b); //way4(b, b + 4, end); int t1 = *a1, t2 = *a2, t3 = *a3; *a1 = *(b + 1); *a2 = *(b + 2); *a3 = t1; *(b + 1) = t2; *(b + 2) = t3; way3(a + 1, b + 1, end, vb, vbb, vend); b = b + 1; swap(a, b); way4(vb, vbb, vend); int *b1 = b + 1; swap(a1, b1); way4(vb, vbb, vend); swap(a2, b1); way4(vb, vbb, vend); swap(a3, b1); way4(vb, vbb, vend); // //这两句话是生成一种 swap(a, a1); swap(a1, b1); swap(a1, a2); way4(vb, vbb, vend); //恢复原状 t1 = *a, t2 = *a1, t3 = *a2; int t4 = *a3; b = vb; while (b < vend - 3) { *(b - 4) = *b; *(b - 3) = *(b + 1); *(b - 2) = *(b + 2); *(b - 1) = *(b + 3); b = b + 4; } *(vend - 4) = t1; *(vend - 3) = t2; *(vend - 2) = t3; *(vend - 1) = t4; }