com.nextgis.maplib.datasource.GeoPoint Java Examples
The following examples show how to use
com.nextgis.maplib.datasource.GeoPoint.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimplePolygonStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onDraw(GeoGeometry geoGeometry, GISDisplay display) { Float textSize = (null == mTextSize) ? null : 12f; float scaledTextSize = (float) (mTextSize * (mWidth / display.getScale())); GeoPoint center = geoGeometry.getEnvelope().getCenter(); switch (geoGeometry.getType()) { case GTPolygon: drawPolygon((GeoPolygon) geoGeometry, display); drawText(scaledTextSize, center, display); break; case GTMultiPolygon: GeoMultiPolygon multiPolygon = (GeoMultiPolygon) geoGeometry; for (int i = 0; i < multiPolygon.size(); i++) { drawPolygon(multiPolygon.get(i), display); drawText(scaledTextSize, center, display); } break; //throw new IllegalArgumentException( // "The input geometry type is not support by this style"); } }
Example #2
Source File: Overlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void drawOnZooming( Canvas canvas, PointF currentFocusLocation, float scale, OverlayItem overlayItem, boolean scaleMarker) { if(null == canvas || null == overlayItem || null == overlayItem.getMarker()) return; if (!isVisible()) return; GeoPoint offset = getScaledOffset(currentFocusLocation, overlayItem, scale, scaleMarker); float zoomedX = (float) (overlayItem.getScreenX() - offset.getX()); float zoomedY = (float) (overlayItem.getScreenY() - offset.getY()); Matrix matrix = new Matrix(); if (scaleMarker) { matrix.postScale(scale, scale); } matrix.postTranslate(zoomedX, zoomedY); canvas.drawBitmap(overlayItem.getMarker(), matrix, null); }
Example #3
Source File: DrawItem.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
public boolean intersectsEdges(GeoEnvelope screenEnv) { for (int ring = 0; ring < mDrawItemsEdge.size(); ring++) { float[] items = mDrawItemsEdge.get(ring); for (int i = 0; i < items.length - 1; i += 2) { if (screenEnv.contains(new GeoPoint(items[i], items[i + 1]))) { mSelectedPoint = i + 2; mSelectedRing = ring; insertNewPoint(mSelectedPoint, items[i], items[i + 1]); return true; } } } return false; }
Example #4
Source File: SimpleTiledPolygonStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
protected void appendPath(Path polygonPath, List<GeoPoint> points) { float x0, y0; if (points.size() > 0) { x0 = (float) points.get(0).getX(); y0 = (float) points.get(0).getY(); polygonPath.moveTo(x0, y0); for (int i = 1; i < points.size(); i++) { x0 = (float) points.get(i).getX(); y0 = (float) points.get(i).getY(); polygonPath.lineTo(x0, y0); } polygonPath.close(); } }
Example #5
Source File: DrawItem.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
public boolean intersectsVertices(GeoEnvelope screenEnv) { int point; for (int ring = 0; ring < mDrawItemsVertex.size(); ring++) { point = 0; float[] items = mDrawItemsVertex.get(ring); for (int i = 0; i < items.length - 1; i += 2) { if (screenEnv.contains(new GeoPoint(items[i], items[i + 1]))) { mSelectedRing = ring; mSelectedPoint = point; return true; } point += 2; } } return false; }
Example #6
Source File: RulerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void fillGeometry() { mRulerString.clear(); mRulerPolygon.clear(); float[] points = mRulerItem.getRing(0); if (points != null) { GeoPoint[] geoPoints = mMapViewOverlays.getMap().screenToMap(points); for (GeoPoint geoPoint : geoPoints) { mRulerString.add(geoPoint); if (geoPoints.length > 2) mRulerPolygon.add(geoPoint); } if (mListener != null) mListener.onLengthChanged(getLength()); if (mListener != null && geoPoints.length > 2) mListener.onAreaChanged(getArea()); } }
Example #7
Source File: MapDrawable.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
/** * Set new map extent according zoom level and center * * @param zoom * A zoom level * @param center * A map center coordinates */ @Override public void setZoomAndCenter( float zoom, GeoPoint center) { if (mDisplay != null) { float newZoom = zoom; if (zoom < mDisplay.getMinZoomLevel()) { newZoom = mDisplay.getMinZoomLevel(); } else if (zoom > mDisplay.getMaxZoomLevel()) { newZoom = mDisplay.getMaxZoomLevel(); } newZoom = Math.round(newZoom); mDisplay.setZoomAndCenter(newZoom, center); onExtentChanged((int) newZoom, center); } }
Example #8
Source File: OverlayItem.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
public void setCoordinates(GeoPoint point) { if (point != null) { switch (point.getCRS()) { case GeoConstants.CRS_WGS84: setCoordinatesFromWGS(point.getX(), point.getY()); break; case GeoConstants.CRS_WEB_MERCATOR: mCoordinates.setCoordinates(point.getX(), point.getY()); break; } mCoordinates.setCRS(point.getCRS()); } updateScreenCoordinates(); }
Example #9
Source File: TrackLayer.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
private void loadTrack(int trackId) { Cursor track = getTrack(trackId); if (track == null || !track.moveToFirst()) { return; } float x0 = track.getFloat(track.getColumnIndex(TrackLayer.FIELD_LON)), y0 = track.getFloat(track.getColumnIndex(TrackLayer.FIELD_LAT)); GeoLineString trackLine = new GeoLineString(); trackLine.setCRS(GeoConstants.CRS_WEB_MERCATOR); trackLine.add(new GeoPoint(x0, y0)); while (track.moveToNext()) { x0 = track.getFloat(track.getColumnIndex(TrackLayer.FIELD_LON)); y0 = track.getFloat(track.getColumnIndex(TrackLayer.FIELD_LAT)); trackLine.add(new GeoPoint(x0, y0)); } mTracks.put(trackId, trackLine); }
Example #10
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected boolean movePointToLocation() { Activity parent = (Activity) mContext; Location location = mGpsEventSource.getLastKnownLocation(); if (null != location) { //change to screen coordinates GeoPoint pt = new GeoPoint(location.getLongitude(), location.getLatitude()); pt.setCRS(GeoConstants.CRS_WGS84); pt.project(GeoConstants.CRS_WEB_MERCATOR); GeoPoint screenPt = mMap.mapToScreen(pt); return moveSelectedPoint((float) screenPt.getX(), (float) screenPt.getY()); } else Toast.makeText(parent, R.string.error_no_location, Toast.LENGTH_SHORT).show(); return false; }
Example #11
Source File: SimpleTiledPolygonStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
protected Path getPath(GeoLineString lineString) { List<GeoPoint> points = lineString.getPoints(); Path path = new Path(); float x0, y0; if (points.size() > 0) { x0 = (float) points.get(0).getX(); y0 = (float) points.get(0).getY(); path.moveTo(x0, y0); for (int i = 1; i < points.size(); i++) { x0 = (float) points.get(i).getX(); y0 = (float) points.get(i).getY(); path.lineTo(x0, y0); } } return path; }
Example #12
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void fillDrawLine(GeoLineString lineString) { GeoPoint[] geoPoints = lineString.getPoints().toArray(new GeoPoint[lineString.getPointCount()]); float[] points = mapToScreen(geoPoints); mSelectedItem = new DrawItem(DrawItem.TYPE_VERTEX, points); mDrawItems.add(mSelectedItem); if (points.length < 2) return; float[] edgePoints = new float[points.length - 2]; for (int i = 0; i < points.length - 2; i++) edgePoints[i] = (points[i] + points[i + 2]) * .5f; mSelectedItem.addEdges(edgePoints); }
Example #13
Source File: SimpleLineStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
protected Path drawSolidLine(float scaledWidth, GeoLineString lineString, GISDisplay display) { Paint paint = new Paint(); paint.setColor(mColor); paint.setAntiAlias(true); paint.setStyle(Paint.Style.STROKE); paint.setStrokeCap(mStrokeCap); paint.setStrokeWidth(scaledWidth); List<GeoPoint> points = lineString.getPoints(); Path path = new Path(); path.incReserve(points.size()); path.moveTo((float) points.get(0).getX(), (float) points.get(0).getY()); for (int i = 1; i < points.size(); ++i) { path.lineTo((float) points.get(i).getX(), (float) points.get(i).getY()); } display.drawPath(path, paint); return path; }
Example #14
Source File: MapEventSource.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
/** * Send extent change event to all listeners * * @param zoom * A zoom level * @param center * A map center coordinates */ @Override protected void onExtentChanged( float zoom, GeoPoint center) { super.onExtentChanged(zoom, center); if (mListeners == null) { return; } Bundle bundle = new Bundle(); bundle.putFloat(BUNDLE_ZOOM_KEY, zoom); bundle.putDouble(BUNDLE_X_KEY, center.getX()); bundle.putDouble(BUNDLE_Y_KEY, center.getY()); bundle.putInt(BUNDLE_TYPE_KEY, EVENT_onExtentChanged); Message msg = new Message(); msg.setData(bundle); mHandler.sendMessage(msg); }
Example #15
Source File: SimpleMarkerStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onDraw(GeoGeometry geoGeometry, GISDisplay display) { switch (geoGeometry.getType()) { case GTPoint: GeoPoint pt = (GeoPoint) geoGeometry; onDraw(pt, display); break; case GTMultiPoint: GeoMultiPoint multiPoint = (GeoMultiPoint) geoGeometry; for (int i = 0; i < multiPoint.size(); i++) { onDraw(multiPoint.get(i), display); } break; //throw new IllegalArgumentException( // "The input geometry type is not support by this style"); } }
Example #16
Source File: SimplePolygonStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
protected void appendPath(Path polygonPath, List<GeoPoint> points) { float x0, y0; if (points.size() > 0) { x0 = (float) points.get(0).getX(); y0 = (float) points.get(0).getY(); polygonPath.moveTo(x0, y0); for (int i = 1; i < points.size(); i++) { x0 = (float) points.get(i).getX(); y0 = (float) points.get(i).getY(); polygonPath.lineTo(x0, y0); } polygonPath.close(); } }
Example #17
Source File: GISDisplay.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public GISDisplay(Bitmap backgroundTile) { mBkBitmap = backgroundTile; //set max zoom mMinZoomLevel = 0; mMaxZoomLevel = DEFAULT_MAX_ZOOM; mLimitType = MAP_LIMITS_Y; // default extent // set full Mercator bounds mFullBounds = new GeoEnvelope(-MERCATOR_MAX, MERCATOR_MAX, -MERCATOR_MAX, MERCATOR_MAX); mGeoLimits = mFullBounds; mCenter = mGeoLimits.getCenter(); //default transform matrix mTransformMatrix = new Matrix(); mInvertTransformMatrix = new Matrix(); mMapTileSize = new GeoPoint(); setSize(300, 300); mRasterPaint = new Paint(); mRasterPaint.setAntiAlias(true); mRasterPaint.setFilterBitmap(true); mRasterPaint.setDither(true); }
Example #18
Source File: GISDisplay.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public synchronized void draw( Canvas canvas, float x, float y, float scale) { clearBackground(canvas); if (null == canvas) { return; } GeoPoint pt = getScaledOffset(x, y, scale); float mainBitmapOffsetX = (float) pt.getX(); float mainBitmapOffsetY = (float) pt.getY(); Matrix matrix = new Matrix(); matrix.postScale(scale, scale); matrix.postTranslate(-mainBitmapOffsetX, -mainBitmapOffsetY); //Log.d(TAG, "matix: " + matrix.toShortString()); canvas.drawBitmap(mDoubleBufferBitmap, matrix, mRasterPaint); }
Example #19
Source File: GISDisplay.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public GeoPoint getScaledOffset( float x, float y, float scale) { float dxOld = x - mWidth / 2; float dyOld = y - mHeight / 2; float scaledWidth = mMainBitmap.getWidth() * scale; float scaledHeight = mMainBitmap.getHeight() * scale; GeoPoint ret = new GeoPoint(); ret.setX((scaledWidth - mWidth) / 2 - (1 - scale) * dxOld); ret.setY((scaledHeight - mHeight) / 2 - (1 - scale) * dyOld); return ret; }
Example #20
Source File: MapView.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void zoomStop() { if (mDrawingState == DRAW_STATE_zooming && mMap != null) { float zoom = MapUtil.getZoomForScaleFactor(mScaleFactor, mMap.getZoomLevel()); GeoEnvelope env = mMap.getFullScreenBounds(); GeoPoint focusPt = new GeoPoint(-mCurrentFocusLocation.x, -mCurrentFocusLocation.y); double invertScale = 1 / mScaleFactor; double offX = (1 - invertScale) * focusPt.getX(); double offY = (1 - invertScale) * focusPt.getY(); env.scale(invertScale); env.offset(offX, offY); GeoPoint newCenterPt = env.getCenter(); GeoPoint newCenterPtMap = mMap.screenToMap(newCenterPt); if(Constants.DEBUG_MODE) { Log.d(TAG, "zoomStop: setZoomAndCenter"); } setZoomAndCenter(zoom, newCenterPtMap); } }
Example #21
Source File: GISDisplay.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public void drawBitmap( Bitmap bitmap, GeoPoint point, float offsetX, float offsetY) { if (null == mMainCanvas) { return; } Matrix matrix = new Matrix(); matrix.postScale((float) mInvertScale, (float) -mInvertScale); matrix.postTranslate((float) point.getX(), (float) point.getY()); matrix.postTranslate((float) (offsetX / mScale), (float) (offsetY / mScale)); mMainCanvas.drawBitmap(bitmap, matrix, new Paint(Paint.ANTI_ALIAS_FLAG)); }
Example #22
Source File: GISDisplay.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public float[] mapToScreen(final GeoPoint[] points) { if (null == points) { return null; } float dfPoints[] = new float[points.length * 2]; for (int i = 0; i < points.length; i++) { int pos = i * 2; dfPoints[pos] = (float) points[i].getX(); dfPoints[pos + 1] = (float) points[i].getY(); } mTransformMatrix.mapPoints(dfPoints); return dfPoints; }
Example #23
Source File: CurrentLocationOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
private void autopanTo(Location autopanLocation, Location location) { GeoPoint oldLocation = new GeoPoint(autopanLocation.getLongitude(), autopanLocation.getLatitude()); GeoPoint newLocation = new GeoPoint(location.getLongitude(), location.getLatitude()); oldLocation.setCRS(GeoConstants.CRS_WGS84); oldLocation.project(GeoConstants.CRS_WEB_MERCATOR); newLocation.setCRS(GeoConstants.CRS_WGS84); newLocation.project(GeoConstants.CRS_WEB_MERCATOR); double dx = oldLocation.getX() - newLocation.getX(); double dy = oldLocation.getY() - newLocation.getY(); GeoPoint newCenter = mMapViewOverlays.getMapCenter(); newCenter.setX(newCenter.getX() - dx); newCenter.setY(newCenter.getY() - dy); mMapViewOverlays.panTo(newCenter); }
Example #24
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void fillDrawRing(GeoLinearRing geoLinearRing) { GeoPoint[] geoPoints = geoLinearRing.getPoints().toArray(new GeoPoint[geoLinearRing.getPointCount()]); float[] points = mapToScreen(geoPoints); float[] edgePoints = new float[points.length]; if (points.length == 0 || edgePoints.length < 2) return; for (int i = 0; i < points.length - 2; i++) edgePoints[i] = (points[i] + points[i + 2]) * .5f; edgePoints[edgePoints.length - 2] = (points[0] + points[points.length - 2]) * .5f; edgePoints[edgePoints.length - 1] = (points[1] + points[points.length - 1]) * .5f; mSelectedItem.addVertices(points); mSelectedItem.addEdges(edgePoints); }
Example #25
Source File: MapDrawable.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public GeoPoint[] screenToMap(float[] points) { if (mDisplay != null && points != null) { return mDisplay.screenToMap(points); } return new GeoPoint[]{}; }
Example #26
Source File: SimplePolygonStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
protected void drawText(Float scaledTextSize, GeoPoint center, GISDisplay display) { if (TextUtils.isEmpty(mText) || null == scaledTextSize) { return; } Paint textPaint = new Paint(); textPaint.setColor(Color.BLACK); textPaint.setAntiAlias(true); textPaint.setStyle(Paint.Style.FILL); textPaint.setStrokeCap(Paint.Cap.ROUND); textPaint.setAlpha(128); Rect textRect = new Rect(); textPaint.setTextSize(scaledTextSize); textPaint.getTextBounds(mText, 0, mText.length(), textRect); float halfW = textRect.width() / 2; float halfH = textRect.height() / 2; float textX = (float) (center.getX() - halfW); float textY = (float) (center.getY() + halfH); Path textPath = new Path(); textPaint.getTextPath(mText, 0, mText.length(), textX, textY, textPath); textPath.close(); Matrix matrix = new Matrix(); matrix.reset(); matrix.setScale(1, -1, (float) center.getX(), (float) center.getY()); textPath.transform(matrix); display.drawPath(textPath, textPaint); }
Example #27
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
protected void onExtentChanged( float zoom, GeoPoint center) { if (mParent != null && mParent instanceof LayerGroup) { LayerGroup group = (LayerGroup) mParent; group.onExtentChanged(zoom, center); } }
Example #28
Source File: SimpleMarkerStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
protected void drawCircleMarker(float scaledSize, float width, GeoPoint pt, GISDisplay display) { if (scaledSize < 2) { mOutPaint.setColor(mColor); mOutPaint.setStrokeWidth(scaledSize); display.drawCircle((float) pt.getX(), (float) pt.getY(), mOutPaint); } else display.drawCircle((float) pt.getX(), (float) pt.getY(), scaledSize, mFillPaint); mOutPaint.setStrokeWidth(width); if (scaledSize >= 2) { mOutPaint.setColor(mOutColor); display.drawCircle((float) pt.getX(), (float) pt.getY(), scaledSize, mOutPaint); } }
Example #29
Source File: SimpleMarkerStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
protected void drawTriangleMarker(float scaledSize, float width, GeoPoint pt, GISDisplay display) { Path path = new Path(); path.moveTo((float) pt.getX() + scaledSize, (float) pt.getY() - scaledSize); path.lineTo((float) pt.getX(), (float) pt.getY() + scaledSize); path.lineTo((float) pt.getX() - scaledSize, (float) pt.getY() - scaledSize); path.close(); drawPath(width, path, display); }
Example #30
Source File: SimplePolygonStyle.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
protected Path getPath(GeoPolygon polygon) { List<GeoPoint> points = polygon.getOuterRing().getPoints(); Path polygonPath = new Path(); appendPath(polygonPath, points); for (int i = 0; i < polygon.getInnerRingCount(); i++) { points = polygon.getInnerRing(i).getPoints(); appendPath(polygonPath, points); } polygonPath.setFillType(Path.FillType.EVEN_ODD); return polygonPath; }