Set "Place doesn't exist" text in core when making a note.

This commit is contained in:
Sergey Magidovich 2016-04-15 21:12:24 +03:00
parent 956647dc11
commit 6ccd95c7cf
5 changed files with 18 additions and 11 deletions

View file

@ -121,7 +121,7 @@ void ServerApi06::CloseChangeSet(uint64_t changesetId) const
uint64_t ServerApi06::CreateNote(ms::LatLon const & ll, string const & message) const
{
CHECK(!message.empty(), ("Note content should not be empty."));
string const params = "?lat=" + strings::to_string_dac(ll.lat, 7) + "&lon=" + strings::to_string_dac(ll.lon, 7) + "&text=" + UrlEncode(message + " #mapsme");
string const params = "?lat=" + strings::to_string_dac(ll.lat, 7) + "&lon=" + strings::to_string_dac(ll.lon, 7) + "&text=" + UrlEncode(message);
OsmOAuth::Response const response = m_auth.Request("/notes" + params, "POST");
if (response.first != OsmOAuth::HTTP::OK)
MYTHROW(ErrorAddingNote, ("Could not post a new note:", response));

View file

@ -915,9 +915,13 @@ bool Editor::CreatePoint(uint32_t type, m2::PointD const & mercator, MwmSet::Mwm
return true;
}
void Editor::CreateNote(ms::LatLon const & latLon, string const & note)
void Editor::CreateNote(ms::LatLon const & latLon, FeatureID const & fid, string const & note)
{
m_notes->CreateNote(latLon, note);
auto const version = GetMwmCreationTimeByMwmId(fid.m_mwmId);
auto const stringVersion = my::TimestampToString(my::SecondsSinceEpochToTimeT(version));
ostringstream sstr(note, ios_base::ate);
sstr << " #mapsme: OSM snapshot version: " << stringVersion;
m_notes->CreateNote(latLon, sstr.str());
}
void Editor::UploadNotes(string const & key, string const & secret)
@ -936,4 +940,6 @@ string DebugPrint(Editor::FeatureStatus fs)
case Editor::FeatureStatus::Created: return "Created";
};
}
char const * const Editor::kPlaceDoesNotExistMessage = "The place has gone or never existed. This is an auto-generated note from MAPS.ME application: a user reports a POI that is visible on a map (which can be outdated), but cannot be found on the ground.";
} // namespace osm

View file

@ -114,9 +114,13 @@ public:
// Editor should silently ignore all types in config which are unknown to him.
NewFeatureCategories GetNewFeatureCategories() const;
bool CreatePoint(uint32_t type, m2::PointD const & mercator, MwmSet::MwmId const & id, EditableMapObject & outFeature);
bool CreatePoint(uint32_t type, m2::PointD const & mercator,
MwmSet::MwmId const & id, EditableMapObject & outFeature);
void CreateNote(ms::LatLon const & latLon, string const & note);
// Predefined messages.
static const char * const kPlaceDoesNotExistMessage;
void CreateNote(ms::LatLon const & latLon, FeatureID const & fid, string const & note);
void UploadNotes(string const & key, string const & secret);
struct Stats

View file

@ -30,7 +30,7 @@
NSAssert(!note.empty(), @"String can't be empty!");
auto const & featureID = MapsAppDelegate.theApp.mapViewController.controlsManager.placePageEntity.info.GetID();
auto const latLon = ToLatLon(m_point);
osm::Editor::Instance().CreateNote(latLon, note);
osm::Editor::Instance().CreateNote(latLon, featureID, note);
[Statistics logEvent:kStatEditorProblemReport withParameters:@{kStatEditorMWMName : @(featureID.GetMwmName().c_str()),
kStatEditorMWMVersion : @(featureID.GetMwmVersion()),
kStatProblem : @(note.c_str()),

View file

@ -1,10 +1,7 @@
#import "MWMReportProblemController.h"
#import "SelectableCell.h"
namespace
{
string const kAmenityDoesntExist = "The amenity has gone or never existed. This is an auto-generated note from MAPS.ME application: a user reports a POI that is visible on a map (which can be a month old), but cannot be found on the ground.";
}
#include "indexer/osm_editor.hpp"
@interface MWMReportProblemController ()
@ -32,7 +29,7 @@ namespace
{
if (!self.isCellSelected)
return;
[self sendNote:kAmenityDoesntExist];
[self sendNote:osm::Editor::kPlaceDoesNotExistMessage];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender