Java Code Examples for com.nextgis.maplib.util.GeoConstants#GTLineString
The following examples show how to use
com.nextgis.maplib.util.GeoConstants#GTLineString .
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: LayerUtil.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
public static String getGeometryName(Context context, int geometryType) { switch (geometryType) { case GeoConstants.GTPoint: return context.getString(R.string.point); case GeoConstants.GTMultiPoint: return context.getString(R.string.multi_point); case GeoConstants.GTLineString: return context.getString(R.string.linestring); case GeoConstants.GTMultiLineString: return context.getString(R.string.multi_linestring); case GeoConstants.GTPolygon: return context.getString(R.string.polygon); case GeoConstants.GTMultiPolygon: return context.getString(R.string.multi_polygon); default: return context.getString(R.string.n_a); } }
Example 2
Source File: DrawItem.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
public static int getMinPointCount(int type) { switch (type) { case GeoConstants.GTPoint: case GeoConstants.GTMultiPoint: return 1; case GeoConstants.GTLineString: case GeoConstants.GTMultiLineString: return 2; case GeoConstants.GTPolygon: case GeoConstants.GTMultiPolygon: return 3; default: return 1; } }
Example 3
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
protected boolean addGeometryToMulti(int geometryType) { //insert geometry in appropriate position switch (geometryType) { case GeoConstants.GTPoint: case GeoConstants.GTLineString: case GeoConstants.GTPolygon: float[] geoPoints = getNewGeometry(geometryType, mTolerancePX, mMap); mSelectedItem = new DrawItem(DrawItem.TYPE_VERTEX, geoPoints); mDrawItems.add(mSelectedItem); break; } return true; }
Example 4
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
public void setGeometryFromWalkEdit(GeoGeometry geometry) { int selectedGeometry = mDrawItems.indexOf(mSelectedItem); int selectedRing = mSelectedItem.getSelectedRingId(); switch (mLayer.getGeometryType()) { case GeoConstants.GTLineString: mFeature.setGeometry(geometry); break; case GeoConstants.GTMultiLineString: GeoMultiLineString multiLine = (GeoMultiLineString) mFeature.getGeometry(); multiLine.set(selectedGeometry, geometry); mFeature.setGeometry(multiLine); break; case GeoConstants.GTPolygon: GeoPolygon polygon = (GeoPolygon) mFeature.getGeometry(); if (selectedRing == 0) polygon.setOuterRing((GeoLinearRing) geometry); else polygon.setInnerRing(selectedRing - 1, (GeoLinearRing) geometry); mFeature.setGeometry(polygon); break; case GeoConstants.GTMultiPolygon: GeoMultiPolygon multiPolygon = (GeoMultiPolygon) mFeature.getGeometry(); GeoPolygon selectedPolygon = multiPolygon.get(selectedGeometry); selectedPolygon.setOuterRing((GeoLinearRing) geometry); if (selectedRing == 0) selectedPolygon.setOuterRing((GeoLinearRing) geometry); else selectedPolygon.setInnerRing(selectedRing - 1, (GeoLinearRing) geometry); multiPolygon.set(selectedGeometry, selectedPolygon); mFeature.setGeometry(multiPolygon); break; } }
Example 5
Source File: GeoGeometryFactory.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
public static GeoGeometry fromDataStream(DataInputStream stream) throws IOException { int geometryType = stream.readInt(); GeoGeometry result = null; switch (geometryType){ case GeoConstants.GTPoint: result = new GeoPoint(); result.read(stream); break; case GeoConstants.GTLineString: result = new GeoLineString(); result.read(stream); break; case GeoConstants.GTLinearRing: result = new GeoLinearRing(); result.read(stream); break; case GeoConstants.GTPolygon: result = new GeoPolygon(); result.read(stream); break; case GeoConstants.GTMultiPoint: result = new GeoMultiPoint(); result.read(stream); break; case GeoConstants.GTMultiLineString: result = new GeoMultiLineString(); result.read(stream); break; case GeoConstants.GTMultiPolygon: result = new GeoMultiPolygon(); result.read(stream); break; case GeoConstants.GTGeometryCollection: result = new GeoGeometryCollection(); result.read(stream); break; } return result; }
Example 6
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
public static float[] getNewGeometry(int geometryType, float tolerance, MapDrawable map) { float[] geoPoints; float add = tolerance * 2; GeoPoint center = map.getFullScreenBounds().getCenter(); switch (geometryType) { case GeoConstants.GTPoint: case GeoConstants.GTMultiPoint: geoPoints = new float[2]; geoPoints[0] = (float) center.getX(); geoPoints[1] = (float) center.getY(); return geoPoints; case GeoConstants.GTLineString: case GeoConstants.GTMultiLineString: geoPoints = new float[4]; geoPoints[0] = (float) center.getX() - add; geoPoints[1] = (float) center.getY() - add; geoPoints[2] = (float) center.getX() + add; geoPoints[3] = (float) center.getY() + add; return geoPoints; case GeoConstants.GTPolygon: case GeoConstants.GTMultiPolygon: geoPoints = new float[6]; geoPoints[0] = (float) center.getX() - add; geoPoints[1] = (float) center.getY() - add; geoPoints[2] = (float) center.getX() - add; geoPoints[3] = (float) center.getY() + add; geoPoints[4] = (float) center.getX() + add; geoPoints[5] = (float) center.getY() + add; return geoPoints; case GeoConstants.GTLinearRing: geoPoints = new float[6]; geoPoints[0] = (float) center.getX() + add; geoPoints[1] = (float) center.getY() + add; geoPoints[2] = (float) center.getX() - add; geoPoints[3] = (float) center.getY() + add; geoPoints[4] = (float) center.getX() - add; geoPoints[5] = (float) center.getY() - add; return geoPoints; default: return null; } }
Example 7
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
protected void startGeometryByWalk() { // register broadcast events IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WalkEditService.WALKEDIT_CHANGE); mReceiver = new WalkEditReceiver(); mContext.registerReceiver(mReceiver, intentFilter); mHasEdits = true; if (WalkEditService.isServiceRunning(mContext)) return; // start service if not started yet GeoGeometry geometry = mFeature.getGeometry(); int selectedRing = mSelectedItem.getSelectedRingId(); int selectedGeometry = mDrawItems.indexOf(mSelectedItem); switch (mLayer.getGeometryType()) { case GeoConstants.GTLineString: break; case GeoConstants.GTPolygon: GeoPolygon polygon = ((GeoPolygon) geometry); geometry = selectedRing == 0 ? polygon.getOuterRing() : polygon.getInnerRing(selectedRing - 1); break; case GeoConstants.GTMultiLineString: geometry = ((GeoMultiLineString) geometry).get(selectedGeometry); break; case GeoConstants.GTMultiPolygon: GeoPolygon selectedPolygon = ((GeoMultiPolygon) geometry).get(selectedGeometry); geometry = selectedRing == 0 ? selectedPolygon.getOuterRing() : selectedPolygon.getInnerRing(selectedRing - 1); break; default: return; } Intent trackerService = new Intent(mContext, WalkEditService.class); trackerService.setAction(WalkEditService.ACTION_START); trackerService.putExtra(ConstantsUI.KEY_LAYER_ID, mLayer.getId()); trackerService.putExtra(ConstantsUI.KEY_GEOMETRY, geometry); trackerService.putExtra(ConstantsUI.TARGET_CLASS, mContext.getClass().getName()); ContextCompat.startForegroundService(mContext, trackerService); }
Example 8
Source File: EditLayerOverlay.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
public void fillDrawItems(GeoGeometry geom) { int lastItemsCount = mDrawItems.size(); int lastSelectedItemPosition = mDrawItems.indexOf(mSelectedItem); DrawItem lastSelectedItem = mSelectedItem; mDrawItems.clear(); if (null == geom) { Log.w(Constants.TAG, "the geometry is null in fillDrawItems method"); return; } GeoPoint[] geoPoints = new GeoPoint[1]; Location last = mGpsEventSource.getLastKnownLocation(); switch (geom.getType()) { case GeoConstants.GTPoint: geoPoints[0] = (GeoPoint) geom; mSelectedItem = new DrawItem(DrawItem.TYPE_VERTEX, mapToScreen(geoPoints)); mDrawItems.add(mSelectedItem); break; case GeoConstants.GTMultiPoint: GeoMultiPoint geoMultiPoint = (GeoMultiPoint) geom; for (int i = 0; i < geoMultiPoint.size(); i++) { geoPoints[0] = geoMultiPoint.get(i); mSelectedItem = new DrawItem(DrawItem.TYPE_VERTEX, mapToScreen(geoPoints)); mDrawItems.add(mSelectedItem); } break; case GeoConstants.GTLineString: fillDrawLine((GeoLineString) geom); break; case GeoConstants.GTMultiLineString: GeoMultiLineString multiLineString = (GeoMultiLineString) geom; for (int i = 0; i < multiLineString.size(); i++) fillDrawLine(multiLineString.get(i)); break; case GeoConstants.GTPolygon: fillDrawPolygon((GeoPolygon) geom); break; case GeoConstants.GTMultiPolygon: GeoMultiPolygon multiPolygon = (GeoMultiPolygon) geom; for (int i = 0; i < multiPolygon.size(); i++) fillDrawPolygon(multiPolygon.get(i)); break; case GeoConstants.GTGeometryCollection: GeoGeometryCollection collection = (GeoGeometryCollection) geom; for (int i = 0; i < collection.size(); i++) { GeoGeometry geoGeometry = collection.get(i); fillDrawItems(geoGeometry); } break; default: break; } if (mDrawItems.size() == lastItemsCount && lastSelectedItem != null && lastSelectedItemPosition != Constants.NOT_FOUND) { mSelectedItem = mDrawItems.get(lastSelectedItemPosition); mSelectedItem.setSelectedRing(lastSelectedItem.getSelectedRingId()); mSelectedItem.setSelectedPoint(lastSelectedItem.getSelectedPointId()); } else { mSelectedItem = mDrawItems.get(0); } switch (geom.getType()) { case GeoConstants.GTPoint: case GeoConstants.GTMultiPoint: updateDistance(last, null); break; } }
Example 9
Source File: GeoLineString.java From android_maplib with GNU Lesser General Public License v3.0 | 4 votes |
@Override public int getType() { return GeoConstants.GTLineString; }