Henning P.
- Forum-Beiträge: 2
26.09.2012, 10:25:30 via Website
26.09.2012 10:25:30 via Website
Hallo zusammen,
ich verzweifle gerade an folgendem Problem:
Ich habe ein Overlay, welches mir an einer gegebenen Position einen Kreis zeichnet. Soweit so gut, das funktioniert wie erwartet.
Jetzt habe ich allerdings noch einen Anfangswinkel und einen Endwinkel, es soll also kein kompletter Kreis gezeichnet werden, sondern nur der Ausschnitt der beiden angegebenen Winkel. Bei Anfangswinkel 0° und Endwinkel 90° quasi der rechte obere Quadrant.
Ich vermute, dass ist dort mit drawArc arbeiten kann. Allerdings habe bereits Probleme die beiden Punkte (Anfangswinkel,Endwinkel) auf dem Kreis darzustellen. Ich hab es so versucht:
(analog dazu mit dem Startwinkel). Leider ist der Punkt an einer falschen Stelle. Longitude stimmt, Latitude ist falsch. Der Punkt ist nicht auf der Kreislinie, sondern viel näher am Mittelpunkt.
Wo habe ich den Denkfehler?
Vielen Dank schonmal im Vorraus!
ich verzweifle gerade an folgendem Problem:
Ich habe ein Overlay, welches mir an einer gegebenen Position einen Kreis zeichnet. Soweit so gut, das funktioniert wie erwartet.
1public void draw(Canvas canvas, MapView mapView, boolean shadow) {
2 super.draw(canvas, mapView, shadow);
3 Projection projection = mapView.getProjection();
4
5 GeoPoint position = new GeoPoint((int) (latitude * 1e6), (int) (longitude * 1e6));
6
7 Point point = projection.toPixels(position, null);
8 float radius = projection.metersToEquatorPixels(r) * (1 / FloatMath.cos((float) Math.toRadians(latitude)));
9
10 canvas.drawCircle((float) point.x, (float) point.y, radius, getCirclePaint());
11 }
2 super.draw(canvas, mapView, shadow);
3 Projection projection = mapView.getProjection();
4
5 GeoPoint position = new GeoPoint((int) (latitude * 1e6), (int) (longitude * 1e6));
6
7 Point point = projection.toPixels(position, null);
8 float radius = projection.metersToEquatorPixels(r) * (1 / FloatMath.cos((float) Math.toRadians(latitude)));
9
10 canvas.drawCircle((float) point.x, (float) point.y, radius, getCirclePaint());
11 }
Jetzt habe ich allerdings noch einen Anfangswinkel und einen Endwinkel, es soll also kein kompletter Kreis gezeichnet werden, sondern nur der Ausschnitt der beiden angegebenen Winkel. Bei Anfangswinkel 0° und Endwinkel 90° quasi der rechte obere Quadrant.
Ich vermute, dass ist dort mit drawArc arbeiten kann. Allerdings habe bereits Probleme die beiden Punkte (Anfangswinkel,Endwinkel) auf dem Kreis darzustellen. Ich hab es so versucht:
1double latEnd = latitude * 1E6 + (r * Math.sin(Math.toRadians(90)));
2double longEnd = longitude * 1E6 + (r * Math.cos(Math.toRadians(90)));
3GeoPoint geoPoint = new GeoPoint((int) latEnd, (int) longEnd);
4Point point = new Point();
5projection.toPixels(geoPoint, point);
6canvas.drawPoint((float) point.x, (float) point.y, endPaint);
2double longEnd = longitude * 1E6 + (r * Math.cos(Math.toRadians(90)));
3GeoPoint geoPoint = new GeoPoint((int) latEnd, (int) longEnd);
4Point point = new Point();
5projection.toPixels(geoPoint, point);
6canvas.drawPoint((float) point.x, (float) point.y, endPaint);
(analog dazu mit dem Startwinkel). Leider ist der Punkt an einer falschen Stelle. Longitude stimmt, Latitude ist falsch. Der Punkt ist nicht auf der Kreislinie, sondern viel näher am Mittelpunkt.
Wo habe ich den Denkfehler?
Vielen Dank schonmal im Vorraus!
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.