|  | @@ -86,6 +86,7 @@ util::http::Answer StatServer::handleMapReq(const Params& pars) const {
 | 
	
		
			
			| 86 | 86 |    auto gret = _idx->getGroups(bbox);
 | 
	
		
			
			| 87 | 87 |    sep = ' ';
 | 
	
		
			
			| 88 | 88 |    for (auto group : gret) {
 | 
	
		
			
			|  | 89 | +    if (group->stations.size() < 2) continue;
 | 
	
		
			
			| 89 | 90 |      json << sep;
 | 
	
		
			
			| 90 | 91 |      sep = ',';
 | 
	
		
			
			| 91 | 92 |      printGroup(group, &json);
 | 
	
	
		
			
			|  | @@ -102,11 +103,18 @@ util::http::Answer StatServer::handleMapReq(const Params& pars) const {
 | 
	
		
			
			| 102 | 103 |  }
 | 
	
		
			
			| 103 | 104 |  
 | 
	
		
			
			| 104 | 105 |  // _____________________________________________________________________________
 | 
	
		
			
			| 105 |  | -void StatServer::printStation(const Station* stat, std::ostream* out) {
 | 
	
		
			
			|  | 106 | +void StatServer::printStation(const Station* stat, std::ostream* out) const {
 | 
	
		
			
			| 106 | 107 |    auto latLng =
 | 
	
		
			
			| 107 | 108 |        util::geo::webMercToLatLng<double>(stat->pos.getX(), stat->pos.getY());
 | 
	
		
			
			| 108 |  | -  (*out) << "{\"id\":" << stat->id << ",\"lat\":"
 | 
	
		
			
			| 109 |  | -         << latLng.getY() << ",\"lon\":" << latLng.getX() << "}";
 | 
	
		
			
			|  | 109 | +  (*out) << "{\"id\":" << stat->id << ",\"lat\":" << latLng.getY()
 | 
	
		
			
			|  | 110 | +         << ",\"lon\":" << latLng.getX();
 | 
	
		
			
			|  | 111 | +
 | 
	
		
			
			|  | 112 | +  if (stat->origGroup != stat->group || _idx->getGroup(stat->group)->osmid == 1)
 | 
	
		
			
			|  | 113 | +    (*out) << ",\"suggestion\":1";
 | 
	
		
			
			|  | 114 | +
 | 
	
		
			
			|  | 115 | +  if (stat->attrErrs.size())
 | 
	
		
			
			|  | 116 | +    (*out) << ",\"attrerrs\":" << stat->attrErrs.size();
 | 
	
		
			
			|  | 117 | +  (*out) << "}";
 | 
	
		
			
			| 110 | 118 |  }
 | 
	
		
			
			| 111 | 119 |  
 | 
	
		
			
			| 112 | 120 |  // _____________________________________________________________________________
 | 
	
	
		
			
			|  | @@ -122,7 +130,9 @@ void StatServer::printGroup(const Group* group, std::ostream* out) {
 | 
	
		
			
			| 122 | 130 |      (*out) << sep << "[" << p.getY() << "," << p.getX() << "]";
 | 
	
		
			
			| 123 | 131 |      sep = ',';
 | 
	
		
			
			| 124 | 132 |    }
 | 
	
		
			
			| 125 |  | -  (*out) << "]}";
 | 
	
		
			
			|  | 133 | +  (*out) << "]";
 | 
	
		
			
			|  | 134 | +  if (group->osmid == 1) (*out) << ",\"new\":1";
 | 
	
		
			
			|  | 135 | +  (*out) << "}";
 | 
	
		
			
			| 126 | 136 |  }
 | 
	
		
			
			| 127 | 137 |  
 | 
	
		
			
			| 128 | 138 |  // _____________________________________________________________________________
 | 
	
	
		
			
			|  | @@ -168,8 +178,8 @@ util::http::Answer StatServer::handleStatReq(const Params& pars) const {
 | 
	
		
			
			| 168 | 178 |  
 | 
	
		
			
			| 169 | 179 |    if (cb.size()) json << cb << "(";
 | 
	
		
			
			| 170 | 180 |    json << "{\"id\":" << sid << ","
 | 
	
		
			
			| 171 |  | -    << "\"osmid\":" << stat->osmid << ","
 | 
	
		
			
			| 172 |  | -    << "\"attrs\":{";
 | 
	
		
			
			|  | 181 | +       << "\"osmid\":" << stat->osmid << ","
 | 
	
		
			
			|  | 182 | +       << "\"attrs\":{";
 | 
	
		
			
			| 173 | 183 |  
 | 
	
		
			
			| 174 | 184 |    char sep = ' ';
 | 
	
		
			
			| 175 | 185 |  
 | 
	
	
		
			
			|  | @@ -182,12 +192,70 @@ util::http::Answer StatServer::handleStatReq(const Params& pars) const {
 | 
	
		
			
			| 182 | 192 |      for (const auto& val : par.second) {
 | 
	
		
			
			| 183 | 193 |        json << sep2;
 | 
	
		
			
			| 184 | 194 |        sep2 = ',';
 | 
	
		
			
			| 185 |  | -      json << util::jsonStringEscape(val);
 | 
	
		
			
			|  | 195 | +      json << "\"" << util::jsonStringEscape(val) << "\"";
 | 
	
		
			
			| 186 | 196 |      }
 | 
	
		
			
			| 187 | 197 |      json << "]";
 | 
	
		
			
			| 188 | 198 |    }
 | 
	
		
			
			| 189 | 199 |  
 | 
	
		
			
			| 190 |  | -  json << "}}";
 | 
	
		
			
			|  | 200 | +  json << "},\"attrerrs\":[";
 | 
	
		
			
			|  | 201 | +
 | 
	
		
			
			|  | 202 | +  sep = ' ';
 | 
	
		
			
			|  | 203 | +  for (const auto& err : stat->attrErrs) {
 | 
	
		
			
			|  | 204 | +    json << sep;
 | 
	
		
			
			|  | 205 | +    sep = ',';
 | 
	
		
			
			|  | 206 | +    const auto otherStat = _idx->getStation(err.otherId);
 | 
	
		
			
			|  | 207 | +    json << "{";
 | 
	
		
			
			|  | 208 | +    json << "\"attr\":[\"" << err.attr << "\",\"" << stat->attrs.at(err.attr)[0]
 | 
	
		
			
			|  | 209 | +         << "\"]";
 | 
	
		
			
			|  | 210 | +    json << ",\"other_attr\":[\"" << err.otherAttr << "\",\""
 | 
	
		
			
			|  | 211 | +         << otherStat->attrs.at(err.otherAttr)[0] << "\"]";
 | 
	
		
			
			|  | 212 | +    json << ",\"conf\":" << err.conf;
 | 
	
		
			
			|  | 213 | +    json << ",\"other\":" << err.otherId;
 | 
	
		
			
			|  | 214 | +    json << ",\"other_osmid\":" << otherStat->osmid;
 | 
	
		
			
			|  | 215 | +    json << "}";
 | 
	
		
			
			|  | 216 | +  }
 | 
	
		
			
			|  | 217 | +
 | 
	
		
			
			|  | 218 | +  json << "]";
 | 
	
		
			
			|  | 219 | +
 | 
	
		
			
			|  | 220 | +  json << ",\"suggestions\":[";
 | 
	
		
			
			|  | 221 | +
 | 
	
		
			
			|  | 222 | +  // suggestions
 | 
	
		
			
			|  | 223 | +  if (stat->group != stat->origGroup || _idx->getGroup(stat->group)->osmid == 1) {
 | 
	
		
			
			|  | 224 | +    if (_idx->getGroup(stat->origGroup)->osmid < 2) {
 | 
	
		
			
			|  | 225 | +      if (_idx->getGroup(stat->group)->osmid == 1) {
 | 
	
		
			
			|  | 226 | +        json << "{\"type\": 1, \"target_gid\":" << stat->group << "}";
 | 
	
		
			
			|  | 227 | +      } else if (_idx->getGroup(stat->group)->osmid > 1) {
 | 
	
		
			
			|  | 228 | +        json << "{\"type\": 2, \"target_gid\":" << stat->group
 | 
	
		
			
			|  | 229 | +             << ",\"target_osm_rel_id\":" << _idx->getGroup(stat->group)->osmid
 | 
	
		
			
			|  | 230 | +             << "}";
 | 
	
		
			
			|  | 231 | +      }
 | 
	
		
			
			|  | 232 | +    } else {
 | 
	
		
			
			|  | 233 | +      if (_idx->getGroup(stat->group)->osmid == 1) {
 | 
	
		
			
			|  | 234 | +        json << "{\"type\": 3,\"orig_gid\":" << stat->origGroup
 | 
	
		
			
			|  | 235 | +             << ",\"orig_osm_rel_id\":"
 | 
	
		
			
			|  | 236 | +             << _idx->getGroup(stat->origGroup)->osmid
 | 
	
		
			
			|  | 237 | +             << ",\"target_gid\":" << stat->group << "}";
 | 
	
		
			
			|  | 238 | +      } else if (_idx->getGroup(stat->group)->osmid > 1) {
 | 
	
		
			
			|  | 239 | +        json << "{\"type\": 4,\"orig_gid\":" << stat->origGroup
 | 
	
		
			
			|  | 240 | +             << ",\"orig_osm_rel_id\":"
 | 
	
		
			
			|  | 241 | +             << _idx->getGroup(stat->origGroup)->osmid
 | 
	
		
			
			|  | 242 | +             << ",\"target_gid\":" << stat->group
 | 
	
		
			
			|  | 243 | +             << ",\"target_osm_rel_id\":" << _idx->getGroup(stat->group)->osmid
 | 
	
		
			
			|  | 244 | +             << "}";
 | 
	
		
			
			|  | 245 | +      } else {
 | 
	
		
			
			|  | 246 | +        json << "{\"type\": 5,\"orig_gid\":" << stat->origGroup
 | 
	
		
			
			|  | 247 | +             << ",\"orig_osm_rel_id\":"
 | 
	
		
			
			|  | 248 | +             << _idx->getGroup(stat->origGroup)->osmid
 | 
	
		
			
			|  | 249 | +             << ",\"target_gid\":" << stat->group
 | 
	
		
			
			|  | 250 | +             << ",\"target_osm_rel_id\":" << _idx->getGroup(stat->group)->osmid
 | 
	
		
			
			|  | 251 | +             << "}";
 | 
	
		
			
			|  | 252 | +      }
 | 
	
		
			
			|  | 253 | +    }
 | 
	
		
			
			|  | 254 | +  }
 | 
	
		
			
			|  | 255 | +
 | 
	
		
			
			|  | 256 | +  json << "]";
 | 
	
		
			
			|  | 257 | +
 | 
	
		
			
			|  | 258 | +  json << "}";
 | 
	
		
			
			| 191 | 259 |  
 | 
	
		
			
			| 192 | 260 |    if (cb.size()) json << ")";
 | 
	
		
			
			| 193 | 261 |  
 |