Patrick Brosi 4 years ago
parent
commit
ff29ea156d
3 changed files with 83 additions and 6 deletions
  1. 52 2
      src/osmfixer/index/StatIdx.cpp
  2. 28 1
      src/osmfixer/index/StatIdx.h
  3. 3 3
      web/script.js

+ 52 - 2
src/osmfixer/index/StatIdx.cpp

@@ -186,6 +186,8 @@ void StatIdx::readFromFile(const std::string& path) {
186
     addGroupToMeta(gid, osmid);
186
     addGroupToMeta(gid, osmid);
187
   }
187
   }
188
 
188
 
189
+  _numOSMMetaGroups = _metaGroups.size();
190
+
189
   LOG(INFO) << "Done.";
191
   LOG(INFO) << "Done.";
190
 
192
 
191
   LOG(INFO) << "Init groups";
193
   LOG(INFO) << "Init groups";
@@ -201,6 +203,23 @@ void StatIdx::readFromFile(const std::string& path) {
201
   LOG(INFO) << "Building indices...";
203
   LOG(INFO) << "Building indices...";
202
   initIndex();
204
   initIndex();
203
   LOG(INFO) << "Done.";
205
   LOG(INFO) << "Done.";
206
+
207
+  LOG(INFO) << "Input Stats:";
208
+  LOG(INFO) << _numOSMStations << " OSM stations";
209
+  LOG(INFO) << _numOSMGroups << " OSM groups";
210
+  LOG(INFO) << _numOSMMetaGroups << " OSM meta groups";
211
+
212
+  LOG(INFO) << "Suggestion Stats:";
213
+  LOG(INFO) << _numOK << " objects OK";
214
+  LOG(INFO) << _numDL << " stations should be removed from their group (DL)";
215
+  LOG(INFO) << _numMV << " stations should be moved into another group (MV)";
216
+  LOG(INFO) << _numGR << " stations should be moved into a group (GR)";
217
+  LOG(INFO) << _numCR
218
+            << " stations should be moved into newly created groups (CR)";
219
+  LOG(INFO) << _numER << " tags were marked as erroneous (ER)";
220
+  LOG(INFO) << _numMG << " relations should be merged (MG)";
221
+  LOG(INFO) << _numNM << " objects should be outfitted with a name (NM)";
222
+  LOG(INFO) << _numTR << " station names are most likely track numbers";
204
 }
223
 }
205
 
224
 
206
 // _____________________________________________________________________________
225
 // _____________________________________________________________________________
@@ -214,6 +233,7 @@ void StatIdx::addGroupToMeta(size_t gid, size_t metaId) {
214
 void StatIdx::addStation(int64_t osmid, const util::geo::DLine& geom,
233
 void StatIdx::addStation(int64_t osmid, const util::geo::DLine& geom,
215
                          const util::geo::DLine& latLngs, size_t origGroup,
234
                          const util::geo::DLine& latLngs, size_t origGroup,
216
                          size_t group, const OsmAttrs& attrs) {
235
                          size_t group, const OsmAttrs& attrs) {
236
+  _numOSMStations++;
217
   auto centroid = util::geo::centroid(latLngs);
237
   auto centroid = util::geo::centroid(latLngs);
218
   _stations.emplace_back(Station{_stations.size(),
238
   _stations.emplace_back(Station{_stations.size(),
219
                                  osmid,
239
                                  osmid,
@@ -232,6 +252,7 @@ void StatIdx::addStation(int64_t osmid, const util::geo::DLine& geom,
232
 
252
 
233
 // _____________________________________________________________________________
253
 // _____________________________________________________________________________
234
 void StatIdx::addGroup(size_t osmid, const OsmAttrs& attrs) {
254
 void StatIdx::addGroup(size_t osmid, const OsmAttrs& attrs) {
255
+  if (osmid > 1) _numOSMGroups++;
235
   Group g;
256
   Group g;
236
   g.id = _groups.size();
257
   g.id = _groups.size();
237
   g.osmid = osmid;
258
   g.osmid = osmid;
@@ -254,7 +275,6 @@ void StatIdx::initMetaGroups() {
254
     mg.poly = hull(mp, 11);
275
     mg.poly = hull(mp, 11);
255
     assert(mg.poly.getOuter().size());
276
     assert(mg.poly.getOuter().size());
256
 
277
 
257
-
258
     for (auto p : mg.poly.getOuter()) {
278
     for (auto p : mg.poly.getOuter()) {
259
       mg.llPoly.getOuter().push_back(
279
       mg.llPoly.getOuter().push_back(
260
           util::geo::webMercToLatLng<double>(p.getX(), p.getY()));
280
           util::geo::webMercToLatLng<double>(p.getX(), p.getY()));
@@ -680,6 +700,8 @@ void StatIdx::initSuggestions() {
680
       sug.type = 7;
700
       sug.type = 7;
681
       _suggestions.push_back(sug);
701
       _suggestions.push_back(sug);
682
       group.suggestions.push_back(_suggestions.size() - 1);
702
       group.suggestions.push_back(_suggestions.size() - 1);
703
+
704
+      if (group.osmid > 2) _numNM++;
683
     }
705
     }
684
 
706
 
685
     Suggestion sug;
707
     Suggestion sug;
@@ -699,6 +721,8 @@ void StatIdx::initSuggestions() {
699
         auto b = util::geo::centroid(
721
         auto b = util::geo::centroid(
700
             getMetaGroup(getGroup(group.mergeId)->metaGroupId)->poly);
722
             getMetaGroup(getGroup(group.mergeId)->metaGroupId)->poly);
701
         sug.arrow = getGroupArrow(a, b);
723
         sug.arrow = getGroupArrow(a, b);
724
+
725
+        _numMG++;
702
       } else {
726
       } else {
703
         // merge two groups
727
         // merge two groups
704
         sug.type = 9;
728
         sug.type = 9;
@@ -710,6 +734,8 @@ void StatIdx::initSuggestions() {
710
         auto a = util::geo::centroid(group.poly);
734
         auto a = util::geo::centroid(group.poly);
711
         auto b = util::geo::centroid(getGroup(group.mergeId)->poly);
735
         auto b = util::geo::centroid(getGroup(group.mergeId)->poly);
712
         sug.arrow = getGroupArrow(a, b);
736
         sug.arrow = getGroupArrow(a, b);
737
+
738
+        _numMG++;
713
       }
739
       }
714
 
740
 
715
       _suggestions.push_back(sug);
741
       _suggestions.push_back(sug);
@@ -734,6 +760,9 @@ void StatIdx::initSuggestions() {
734
 
760
 
735
         _suggestions.push_back(sug);
761
         _suggestions.push_back(sug);
736
         group.suggestions.push_back(_suggestions.size() - 1);
762
         group.suggestions.push_back(_suggestions.size() - 1);
763
+
764
+        _numTR++;
765
+        _numER++;
737
       } else if (otherGrp->osmid == group.osmid) {
766
       } else if (otherGrp->osmid == group.osmid) {
738
         if (suggested.count({attrErr.attr, 6})) continue;
767
         if (suggested.count({attrErr.attr, 6})) continue;
739
         // fix attributes
768
         // fix attributes
@@ -747,8 +776,12 @@ void StatIdx::initSuggestions() {
747
 
776
 
748
         _suggestions.push_back(sug);
777
         _suggestions.push_back(sug);
749
         group.suggestions.push_back(_suggestions.size() - 1);
778
         group.suggestions.push_back(_suggestions.size() - 1);
779
+
780
+        _numER++;
750
       }
781
       }
751
     }
782
     }
783
+
784
+    if (group.suggestions.size() + group.attrErrs.size() == 0) _numOK++;
752
   }
785
   }
753
 
786
 
754
   // station suggestions
787
   // station suggestions
@@ -763,6 +796,8 @@ void StatIdx::initSuggestions() {
763
       sug.type = 7;
796
       sug.type = 7;
764
       _suggestions.push_back(sug);
797
       _suggestions.push_back(sug);
765
       stat.suggestions.push_back(_suggestions.size() - 1);
798
       stat.suggestions.push_back(_suggestions.size() - 1);
799
+
800
+      _numNM++;
766
     }
801
     }
767
 
802
 
768
     Suggestion sug;
803
     Suggestion sug;
@@ -789,6 +824,9 @@ void StatIdx::initSuggestions() {
789
 
824
 
790
         _suggestions.push_back(sug);
825
         _suggestions.push_back(sug);
791
         stat.suggestions.push_back(_suggestions.size() - 1);
826
         stat.suggestions.push_back(_suggestions.size() - 1);
827
+
828
+        _numTR++;
829
+        _numER++;
792
       } else if (otherStat->osmid == stat.osmid) {
830
       } else if (otherStat->osmid == stat.osmid) {
793
         if (suggested.count({attrErr.attr, 6})) continue;
831
         if (suggested.count({attrErr.attr, 6})) continue;
794
         suggested.insert({attrErr.attr, 6});
832
         suggested.insert({attrErr.attr, 6});
@@ -802,6 +840,8 @@ void StatIdx::initSuggestions() {
802
 
840
 
803
         _suggestions.push_back(sug);
841
         _suggestions.push_back(sug);
804
         stat.suggestions.push_back(_suggestions.size() - 1);
842
         stat.suggestions.push_back(_suggestions.size() - 1);
843
+
844
+        _numER++;
805
       }
845
       }
806
     }
846
     }
807
 
847
 
@@ -819,6 +859,7 @@ void StatIdx::initSuggestions() {
819
           _suggestions.push_back(sug);
859
           _suggestions.push_back(sug);
820
           stat.suggestions.push_back(_suggestions.size() - 1);
860
           stat.suggestions.push_back(_suggestions.size() - 1);
821
 
861
 
862
+          _numCR++;
822
         } else if (getGroup(stat.group)->osmid > 1) {
863
         } else if (getGroup(stat.group)->osmid > 1) {
823
           // move orphan into existing group
864
           // move orphan into existing group
824
           sug.type = 2;
865
           sug.type = 2;
@@ -830,6 +871,8 @@ void StatIdx::initSuggestions() {
830
 
871
 
831
           _suggestions.push_back(sug);
872
           _suggestions.push_back(sug);
832
           stat.suggestions.push_back(_suggestions.size() - 1);
873
           stat.suggestions.push_back(_suggestions.size() - 1);
874
+
875
+          _numGR++;
833
         }
876
         }
834
       } else {
877
       } else {
835
         if (getGroup(stat.group)->osmid == 1 &&
878
         if (getGroup(stat.group)->osmid == 1 &&
@@ -845,6 +888,8 @@ void StatIdx::initSuggestions() {
845
 
888
 
846
           _suggestions.push_back(sug);
889
           _suggestions.push_back(sug);
847
           stat.suggestions.push_back(_suggestions.size() - 1);
890
           stat.suggestions.push_back(_suggestions.size() - 1);
891
+
892
+          _numCR++;
848
         } else if (getGroup(stat.group)->osmid > 1) {
893
         } else if (getGroup(stat.group)->osmid > 1) {
849
           if (stat.group != getGroup(stat.origGroup)->mergeId) {
894
           if (stat.group != getGroup(stat.origGroup)->mergeId) {
850
             // move station from relation into existing group
895
             // move station from relation into existing group
@@ -852,9 +897,10 @@ void StatIdx::initSuggestions() {
852
             sug.target_gid = stat.group;
897
             sug.target_gid = stat.group;
853
             sug.target_osm_rel_id = getGroup(stat.group)->osmid;
898
             sug.target_osm_rel_id = getGroup(stat.group)->osmid;
854
 
899
 
855
-            // dont output arrow if move is part of a group merge
856
             auto b = util::geo::centroid(getGroup(stat.group)->poly);
900
             auto b = util::geo::centroid(getGroup(stat.group)->poly);
857
             sug.arrow = getGroupArrow(centroid, b);
901
             sug.arrow = getGroupArrow(centroid, b);
902
+
903
+            _numMV++;
858
           } else {
904
           } else {
859
             continue;
905
             continue;
860
             // size_t metaId =
906
             // size_t metaId =
@@ -893,9 +939,13 @@ void StatIdx::initSuggestions() {
893
 
939
 
894
           _suggestions.push_back(sug);
940
           _suggestions.push_back(sug);
895
           stat.suggestions.push_back(_suggestions.size() - 1);
941
           stat.suggestions.push_back(_suggestions.size() - 1);
942
+
943
+          _numDL++;
896
         }
944
         }
897
       }
945
       }
898
     }
946
     }
947
+
948
+    if (stat.suggestions.size() + stat.attrErrs.size() == 0) _numOK++;
899
   }
949
   }
900
 }
950
 }
901
 
951
 

+ 28 - 1
src/osmfixer/index/StatIdx.h

@@ -105,7 +105,19 @@ struct Cluster {
105
 
105
 
106
 class StatIdx {
106
 class StatIdx {
107
  public:
107
  public:
108
-  StatIdx() {}
108
+  StatIdx()
109
+      : _numOSMStations(0),
110
+        _numOSMGroups(0),
111
+        _numOSMMetaGroups(0),
112
+        _numOK(0),
113
+        _numDL(0),
114
+        _numMV(0),
115
+        _numGR(0),
116
+        _numCR(0),
117
+        _numER(0),
118
+        _numMG(0),
119
+        _numNM(0),
120
+        _numTR(0) {}
109
 
121
 
110
   void readFromFile(const std::string& path);
122
   void readFromFile(const std::string& path);
111
 
123
 
@@ -171,6 +183,21 @@ class StatIdx {
171
   std::vector<util::geo::Grid<Cluster, util::geo::Point, double>>
183
   std::vector<util::geo::Grid<Cluster, util::geo::Point, double>>
172
       _heatGridsSugg;
184
       _heatGridsSugg;
173
   std::vector<util::geo::Grid<Cluster, util::geo::Point, double>> _heatGridsErr;
185
   std::vector<util::geo::Grid<Cluster, util::geo::Point, double>> _heatGridsErr;
186
+
187
+  size_t _numOSMStations;
188
+  size_t _numOSMGroups;
189
+  size_t _numOSMMetaGroups;
190
+  size_t _numOK;
191
+  size_t _numDL;
192
+  size_t _numMV;
193
+  size_t _numGR;
194
+  size_t _numCR;
195
+  size_t _numER;
196
+
197
+  size_t _numMG;
198
+
199
+  size_t _numNM;
200
+  size_t _numTR;
174
 };
201
 };
175
 }  // namespace osmfixer
202
 }  // namespace osmfixer
176
 
203
 

+ 3 - 3
web/script.js

@@ -145,7 +145,7 @@ function rndrSt(stat) {
145
 
145
 
146
     if (stat.attrs.name) con.innerHTML += " (<b>\"" + stat.attrs.name + "\"</b>)";
146
     if (stat.attrs.name) con.innerHTML += " (<b>\"" + stat.attrs.name + "\"</b>)";
147
 
147
 
148
-    con.innerHTML += "<a class='ebut' target='_blank' href='" + osmUrl + ident.toLowerCase() + "=" + osmid +"'>&#9998;</a>";
148
+    con.innerHTML += "<a class='ebut' target='_blank' href='" + osmUrl + "edit?" + ident.toLowerCase() + "=" + osmid +"'>&#9998;</a>";
149
 
149
 
150
     var attrTbl = $$('table');
150
     var attrTbl = $$('table');
151
     attrTbl.setAttribute("id", "attr-tbl")
151
     attrTbl.setAttribute("id", "attr-tbl")
@@ -242,7 +242,7 @@ function rndrGr(grp) {
242
 
242
 
243
         if (grp.attrs.name) con.innerHTML += " (<b>\"" + grp.attrs.name + "\"</b>)";
243
         if (grp.attrs.name) con.innerHTML += " (<b>\"" + grp.attrs.name + "\"</b>)";
244
 
244
 
245
-        con.innerHTML += "<a class='ebut' target='_blank' href='https://www.openstreetmap.org/edit?relation=" + grp.osmid +"'>&#9998;</a>";
245
+        con.innerHTML += "<a class='ebut' target='_blank' href='" + osmUrl + "edit?relation=" + grp.osmid +"'>&#9998;</a>";
246
     }
246
     }
247
 
247
 
248
     var attrTbl = $$('table');
248
     var attrTbl = $$('table');
@@ -355,7 +355,7 @@ function rndrMGr(grp) {
355
     oldMembers.innerHTML = "<span class='oldmemberstit'>Members</span>";
355
     oldMembers.innerHTML = "<span class='oldmemberstit'>Members</span>";
356
 
356
 
357
     con.innerHTML = "OSM relation <a target='_blank' href='https://www.openstreetmap.org/relation/" + grp.osmid + "'>" + grp.osmid + " </a> (<tt>public_transport=stop_area_group</tt>)";
357
     con.innerHTML = "OSM relation <a target='_blank' href='https://www.openstreetmap.org/relation/" + grp.osmid + "'>" + grp.osmid + " </a> (<tt>public_transport=stop_area_group</tt>)";
358
-    con.innerHTML += "<a class='ebut' target='_blank' href='https://www.openstreetmap.org/edit?relation=" + grp.osmid +"'>&#9998;</a>";
358
+    con.innerHTML += "<a class='ebut' target='_blank' href='" + osmUrl + "edit?relation=" + grp.osmid +"'>&#9998;</a>";
359
 
359
 
360
     con.appendChild(oldMembers);
360
     con.appendChild(oldMembers);
361
 
361