still cleanup
This commit is contained in:
parent
1f8dbb7694
commit
2869cae3a0
7 changed files with 69 additions and 92 deletions
|
@ -2,8 +2,6 @@ package net.osmand.data;
|
|||
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class RotatedTileBox {
|
||||
|
||||
/// primary fields
|
||||
|
@ -124,11 +122,11 @@ public class RotatedTileBox {
|
|||
public double getCenterTileX(){
|
||||
return oxTile;
|
||||
}
|
||||
|
||||
|
||||
public int getCenter31X(){
|
||||
return MapUtils.get31TileNumberX(lon);
|
||||
}
|
||||
|
||||
|
||||
public int getCenter31Y(){
|
||||
return MapUtils.get31TileNumberY(lat);
|
||||
}
|
||||
|
@ -191,7 +189,7 @@ public class RotatedTileBox {
|
|||
float right = (float) MapUtils.getLongitudeFromTile(zoom, alignTile(tileBounds.right));
|
||||
latLonBounds = new QuadRect(left, top, right, bottom);
|
||||
}
|
||||
|
||||
|
||||
private double alignTile(double tile) {
|
||||
if(tile < 0) {
|
||||
return 0;
|
||||
|
@ -234,7 +232,7 @@ public class RotatedTileBox {
|
|||
double yTile = MapUtils.getTileNumberY(zoom, latitude);
|
||||
return getPixXFromTile(xTile, yTile);
|
||||
}
|
||||
|
||||
|
||||
public float getPixXFromTile(double tileX, double tileY, float zoom) {
|
||||
double pw = MapUtils.getPowZoom(zoom - this.zoom);
|
||||
double xTile = tileX / pw;
|
||||
|
@ -261,7 +259,7 @@ public class RotatedTileBox {
|
|||
double yTile = MapUtils.getTileNumberY(zoom, latitude);
|
||||
return getPixYFromTile(xTile, yTile);
|
||||
}
|
||||
|
||||
|
||||
public float getPixYFromTile(double tileX, double tileY, float zoom) {
|
||||
double pw = MapUtils.getPowZoom(zoom - this.zoom);
|
||||
double xTile = (tileX / pw);
|
||||
|
@ -311,11 +309,11 @@ public class RotatedTileBox {
|
|||
checkTileRectangleCalculated();
|
||||
return latLonBounds;
|
||||
}
|
||||
|
||||
|
||||
public double getRotateCos() {
|
||||
return rotateCos;
|
||||
}
|
||||
|
||||
|
||||
public double getRotateSin() {
|
||||
return rotateSin;
|
||||
}
|
||||
|
@ -363,7 +361,7 @@ public class RotatedTileBox {
|
|||
public double getZoomAnimation() {
|
||||
return zoomAnimation;
|
||||
}
|
||||
|
||||
|
||||
public double getZoomFloatPart() {
|
||||
return zoomFloatPart;
|
||||
}
|
||||
|
@ -374,7 +372,7 @@ public class RotatedTileBox {
|
|||
this.zoom = zoom;
|
||||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
|
||||
public void setZoomAndAnimation(int zoom, double zoomAnimation) {
|
||||
this.zoomAnimation = zoomAnimation;
|
||||
this.zoom = zoom;
|
||||
|
@ -393,20 +391,20 @@ public class RotatedTileBox {
|
|||
MapUtils.getLongitudeFromTile(zoom, alignTile(tileLT.x)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public QuadPointDouble getLeftTopTile(double zoom) {
|
||||
checkTileRectangleCalculated();
|
||||
return new QuadPointDouble((tileLT.x * MapUtils.getPowZoom(zoom - this.zoom)),
|
||||
(tileLT.y * MapUtils.getPowZoom(zoom - this.zoom)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public QuadPointDouble getRightBottomTile(float zoom) {
|
||||
checkTileRectangleCalculated();
|
||||
return new QuadPointDouble((tileRB.x * MapUtils.getPowZoom(zoom - this.zoom)),
|
||||
(tileRB.y * MapUtils.getPowZoom(zoom - this.zoom)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void checkTileRectangleCalculated() {
|
||||
if(tileBounds == null){
|
||||
|
@ -424,7 +422,7 @@ public class RotatedTileBox {
|
|||
this.mapDensity = mapDensity;
|
||||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
|
||||
public double getMapDensity() {
|
||||
return mapDensity;
|
||||
}
|
||||
|
@ -473,7 +471,7 @@ public class RotatedTileBox {
|
|||
double ty = getPixYFromTile(qp.x, qp.y);
|
||||
return tx >= 0 && tx <= pixWidth && ty >= 0 && ty <= pixHeight;
|
||||
}
|
||||
|
||||
|
||||
public boolean containsTilePoint(QuadPointDouble qp) {
|
||||
double tx = getPixXFromTile(qp.x, qp.y);
|
||||
double ty = getPixYFromTile(qp.x, qp.y);
|
||||
|
@ -485,7 +483,7 @@ public class RotatedTileBox {
|
|||
double ty = getPixYFromLatLon(lat, lon);
|
||||
return tx >= 0 && tx <= pixWidth && ty >= 0 && ty <= pixHeight;
|
||||
}
|
||||
|
||||
|
||||
public boolean containsLatLon(LatLon latLon) {
|
||||
double tx = getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
double ty = getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
|
@ -532,7 +530,7 @@ public class RotatedTileBox {
|
|||
zoomSet = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public RotatedTileBoxBuilder setLocation(double lat, double lon) {
|
||||
tb.lat = lat;
|
||||
tb.lon = lon;
|
||||
|
@ -594,6 +592,6 @@ public class RotatedTileBox {
|
|||
+ pixHeight + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -65,9 +65,7 @@
|
|||
<meta-data android:name="com.sec.minimode.icon.landscape.normal" android:resource="@mipmap/icon" android:value="" />
|
||||
<activity android:name="net.osmand.plus.activities.HelpActivity" />
|
||||
<activity android:name="net.osmand.plus.activities.ExitActivity" />
|
||||
<activity android:name=".activities.ServerActivity"
|
||||
android:label="@string/shared_string_settings"
|
||||
android:configChanges="keyboardHidden|orientation" />
|
||||
<activity android:name=".activities.ServerActivity" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
|
|
|
@ -1,51 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="10px">
|
||||
<RelativeLayout
|
||||
android:id="@+id/RelativeLayout03"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="20px"
|
||||
android:layout_marginBottom="40px">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TextView02"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:autoLink="web"
|
||||
android:text="Click button to start server"></TextView>
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/Button01"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/RelativeLayout03"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginBottom="40px"
|
||||
android:text="Start"></Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/Button03"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/Button01"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="Stop"></Button>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10px">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/server_status_textview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignRight="@+id/Button03"
|
||||
android:fitsSystemWindows="true"
|
||||
android:lines="14"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textSize="8dp" />
|
||||
android:textAlignment="center"
|
||||
android:autoLink="web"
|
||||
android:text="@string/click_button_to_start_server"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<Button
|
||||
android:id="@+id/server_start_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/global_start"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/server_stop_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/global_stop"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -11,6 +11,10 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="global_start">Start</string>
|
||||
<string name="global_stop">Stop</string>
|
||||
<string name="click_button_to_start_server">Click button to start server</string>
|
||||
<string name="click_button_to_stop_server">Click second button to deactivate server</string>
|
||||
<string name="web_server">Web server</string>
|
||||
<string name="one_point_error">Please add at least two points.</string>
|
||||
<string name="shared_string_is_saved">is saved</string>
|
||||
|
|
|
@ -27,20 +27,20 @@ public class ServerActivity extends AppCompatActivity {
|
|||
enableStrictMode();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.server_activity);
|
||||
findViewById(R.id.Button01).setOnClickListener(new View.OnClickListener() {
|
||||
findViewById(R.id.server_start_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (!initialized) {
|
||||
updateTextView("Click second button to deactivate server");
|
||||
updateTextView(getString(R.string.click_button_to_stop_server));
|
||||
initServer();
|
||||
}
|
||||
}
|
||||
});
|
||||
findViewById(R.id.Button03).setOnClickListener(new View.OnClickListener() {
|
||||
findViewById(R.id.server_stop_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (initialized) {
|
||||
updateTextView("Click first button to activate server");
|
||||
updateTextView(getString(R.string.click_button_to_start_server));
|
||||
deInitServer();
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class ServerActivity extends AppCompatActivity {
|
|||
|
||||
|
||||
private void updateTextView(String text) {
|
||||
((TextView) findViewById(R.id.TextView02)).setText(text);
|
||||
((TextView) findViewById(R.id.server_status_textview)).setText(text);
|
||||
}
|
||||
|
||||
private void initServer() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import fi.iki.elonen.NanoHTTPD;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.server.endpoints.TileEndpoint;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -45,13 +46,17 @@ public class ApiRouter {
|
|||
public NanoHTTPD.Response route(NanoHTTPD.IHTTPSession session) {
|
||||
Log.d("SERVER", "URI: " + session.getUri());
|
||||
String uri = session.getUri();
|
||||
if (uri.equals("/")) return getStatic("/go.html");
|
||||
if (uri.equals("/")) {
|
||||
return getStatic("/go.html");
|
||||
}
|
||||
if (uri.contains("/scripts/") ||
|
||||
uri.contains("/images/") ||
|
||||
uri.contains("/css/") ||
|
||||
uri.contains("/fonts/") ||
|
||||
uri.contains("/favicon.ico")
|
||||
) return getStatic(uri);
|
||||
) {
|
||||
return getStatic(uri);
|
||||
}
|
||||
if (isApiUrl(uri)) {
|
||||
return routeApi(session);
|
||||
} else {
|
||||
|
@ -86,6 +91,7 @@ public class ApiRouter {
|
|||
private NanoHTTPD.Response routeContent(NanoHTTPD.IHTTPSession session) {
|
||||
String url = session.getUri();
|
||||
//add index page
|
||||
//return getStatic(session.getUri());
|
||||
String responseText = getHtmlPage(url);
|
||||
if (responseText != null) {
|
||||
return newFixedLengthResponse(responseText);
|
||||
|
@ -126,6 +132,13 @@ public class ApiRouter {
|
|||
}
|
||||
|
||||
private String readHTMLFromFile(String filename) {
|
||||
// try {
|
||||
// InputStream is = application.getAssets().open(FOLDER_NAME + filename);
|
||||
// return Algorithms.readFromInputStream(is,false).toString();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try {
|
||||
InputStream is = application.getAssets().open(FOLDER_NAME + filename);
|
||||
|
|
|
@ -578,7 +578,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public void refreshBaseMapInternal(RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||
private void refreshBaseMapInternal(RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||
if (tileBox.getPixHeight() == 0 || tileBox.getPixWidth() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
additional.calculateFPS(start, end);
|
||||
}
|
||||
|
||||
public void refreshMapInternal(DrawSettings drawSettings) {
|
||||
private void refreshMapInternal(DrawSettings drawSettings) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -868,20 +868,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
return currentViewport;
|
||||
}
|
||||
|
||||
public void setCurrentRotatedTileBox(net.osmand.data.RotatedTileBox tileBox) {
|
||||
float rx = (float) tileBox.getCenterPixelX() / tileBox.getPixWidth();
|
||||
float ry = (float) tileBox.getCenterPixelY() / tileBox.getPixHeight();
|
||||
if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) {
|
||||
ry -= 0.35;
|
||||
}
|
||||
tileBox.setCenterLocation(rx, ry);
|
||||
LatLon screenCenter = tileBox.getLatLonFromPixel(tileBox.getPixWidth() / 2f, tileBox.getPixHeight() / 2f);
|
||||
mapRatioX = 0;
|
||||
mapRatioY = 0;
|
||||
setLatLon(screenCenter.getLatitude(), screenCenter.getLongitude());
|
||||
currentViewport = tileBox;
|
||||
}
|
||||
|
||||
public float getDensity() {
|
||||
return currentViewport.getDensity();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue