forked from organicmaps/organicmaps
simplify code
This commit is contained in:
parent
001c33a49e
commit
5edc1de9ef
5 changed files with 50 additions and 22 deletions
|
@ -36,19 +36,35 @@ namespace yopme
|
|||
m_framework.PrepareToShutdown();
|
||||
}
|
||||
|
||||
bool Framework::ShowRect(double lat, double lon, double zoom,
|
||||
bool needApiMark, bool needMyLoc, double myLat, double myLon)
|
||||
bool Framework::ShowMyPosition(double lat, double lon, double zoom)
|
||||
{
|
||||
m2::PointD point(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat));
|
||||
m2::PointD altPoint(MercatorBounds::LonToX(myLon), MercatorBounds::LatToY(myLat));
|
||||
if (!m_framework.IsCountryLoaded(point) && zoom > scales::GetUpperWorldScale())
|
||||
m2::PointD position(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat));
|
||||
if (!m_framework.IsCountryLoaded(position) && zoom > scales::GetUpperWorldScale())
|
||||
return false;
|
||||
|
||||
m_framework.ShowRect(lat, lon, zoom);
|
||||
InitRenderPolicy(needApiMark, point, needMyLoc, altPoint);
|
||||
ShowRect(false, m2::PointD(), true, position);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Framework::ShowPoi(double lat, double lon, bool needMyLoc, double myLat, double myLoc, double zoom)
|
||||
{
|
||||
m2::PointD poi(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat));
|
||||
if (!m_framework.IsCountryLoaded(poi) && zoom > scales::GetUpperWorldScale())
|
||||
return false;
|
||||
|
||||
m_framework.ShowRect(lat, lon, zoom);
|
||||
m2::PointD position(MercatorBounds::LonToX(myLoc), MercatorBounds::LatToY(myLat));
|
||||
ShowRect(true, poi, needMyLoc, position);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Framework::ShowRect(bool needApiPin, m2::PointD const & apiPinPoint,
|
||||
bool needMyLoc, m2::PointD const & myLocPoint)
|
||||
{
|
||||
InitRenderPolicy(needApiPin, apiPinPoint, needMyLoc, myLocPoint);
|
||||
RenderMap();
|
||||
TeardownRenderPolicy();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Framework::InitRenderPolicy(bool needApiPin, m2::PointD const & apiPinPoint,
|
||||
|
@ -78,8 +94,8 @@ namespace yopme
|
|||
m_framework.SetRenderPolicy(rp);
|
||||
m_framework.InitGuiSubsystem();
|
||||
m_framework.OnSize(m_width, m_height);
|
||||
rp->DrawApiPin(needApiPin, m_framework.GtoP(apiPinPoint));
|
||||
rp->DrawMyLocation(needMyLoc, m_framework.GtoP(myLocPoint));
|
||||
rp->SetDrawingApiPin(needApiPin, m_framework.GtoP(apiPinPoint));
|
||||
rp->SetDrawingMyLocation(needMyLoc, m_framework.GtoP(myLocPoint));
|
||||
}
|
||||
catch(RootException & e)
|
||||
{
|
||||
|
|
|
@ -11,10 +11,12 @@ namespace yopme
|
|||
Framework(int width, int height);
|
||||
~Framework();
|
||||
|
||||
bool ShowRect(double lat, double lon, double zoom,
|
||||
bool needApiMark, bool needMyLoc, double myLat, double myLoc);
|
||||
bool ShowMyPosition(double lat, double lon, double zoom);
|
||||
bool ShowPoi(double lat, double lon, bool needMyLoc, double myLat, double myLoc, double zoom);
|
||||
|
||||
private:
|
||||
void ShowRect(bool needApiPin, m2::PointD const & apiPinPoint,
|
||||
bool needMyLoc, m2::PointD const & myLocPoint);
|
||||
void InitRenderPolicy(bool needApiPin, m2::PointD const & apiPinPoint,
|
||||
bool needMyLoc, m2::PointD const & myLocPoint);
|
||||
|
||||
|
|
|
@ -23,13 +23,21 @@ Java_com_mapswithme_yopme_map_MapRenderer_nativeCreateFramework(JNIEnv * env, jo
|
|||
}
|
||||
|
||||
JNIEXPORT bool JNICALL
|
||||
Java_com_mapswithme_yopme_map_MapRenderer_nativeRenderMap(JNIEnv * env, jobject obj,
|
||||
double lat, double lon, double zoom,
|
||||
bool needApiMark, bool needMyLoc,
|
||||
double myLat, double myLon)
|
||||
Java_com_mapswithme_yopme_map_MapRenderer_nativeRenderMyPosition(JNIEnv * env, jobject obj,
|
||||
double lat, double lon, double zoom)
|
||||
{
|
||||
ASSERT(s_framework != NULL, ());
|
||||
return s_framework->ShowRect(lat, lon, zoom, needApiMark, needMyLoc, myLat, myLon);
|
||||
return s_framework->ShowMyPosition(lat, lon, zoom);
|
||||
}
|
||||
|
||||
JNIEXPORT bool JNICALL
|
||||
Java_com_mapswithme_yopme_map_MapRenderer_nativeRenderPoiMap(JNIEnv * env, jobject obj,
|
||||
double lat, double lon,
|
||||
bool needMyLoc, double myLat, double myLon,
|
||||
double zoom)
|
||||
{
|
||||
ASSERT(s_framework != NULL, ());
|
||||
return s_framework->ShowPoi(lat, lon, needMyLoc, myLat, myLon, zoom);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
|
@ -40,7 +40,7 @@ public class MapRenderer implements MapDataProvider
|
|||
final MWMPoint poi = new MWMPoint(lat, lon, "");
|
||||
|
||||
mPixelBuffer.attachToThread();
|
||||
if (nativeRenderMap(lat, lon, zoom, false, true, lat, lon) == false)
|
||||
if (nativeRenderMyPosition(poi.getLat(), poi.getLon(), zoom) == false)
|
||||
return new MapData(null, poi);
|
||||
|
||||
Bitmap bmp = mPixelBuffer.readBitmap();
|
||||
|
@ -55,7 +55,7 @@ public class MapRenderer implements MapDataProvider
|
|||
synchronized(MapRenderer.class)
|
||||
{
|
||||
mPixelBuffer.attachToThread();
|
||||
if (nativeRenderMap(poi.getLat(), poi.getLon(), zoom, true, myLocationDetected, myLat, myLon) == false)
|
||||
if (nativeRenderPoiMap(poi.getLat(), poi.getLon(), myLocationDetected, myLat, myLon, zoom) == false)
|
||||
return new MapData(null, poi);
|
||||
|
||||
Bitmap bmp = mPixelBuffer.readBitmap();
|
||||
|
@ -65,7 +65,8 @@ public class MapRenderer implements MapDataProvider
|
|||
}
|
||||
|
||||
private native void nativeCreateFramework(int width, int height);
|
||||
private native boolean nativeRenderMap(double lat, double lon, double zoom,
|
||||
boolean needApiMark, boolean needMyLocation,
|
||||
double myLat, double myLon);
|
||||
private native boolean nativeRenderMyPosition(double lat, double lon, double zoom);
|
||||
private native boolean nativeRenderPoiMap(double lat, double lon,
|
||||
boolean needMyLocation, double myLat, double myLon,
|
||||
double zoom);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ void GLWidget::initializeGL()
|
|||
YopmeRP * rp = new YopmeRP(rpParams);
|
||||
m_f.SetRenderPolicy(rp);
|
||||
m_f.InitGuiSubsystem();
|
||||
rp->DrawApiPin(true, m2::PointD(100, 100));
|
||||
rp->SetDrawingApiPin(true, m2::PointD(100, 100));
|
||||
rp->SetDrawingMyLocation(true, m2::PointD(200, 100));
|
||||
}
|
||||
catch (RootException & e)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue