Java Code Examples for com.nextgis.maplib.util.GeoConstants#GTPoint

The following examples show how to use com.nextgis.maplib.util.GeoConstants#GTPoint . 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 vote down vote up
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 vote down vote up
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 vote down vote up
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 vote down vote up
@Override
public void drawOnPanning(
        Canvas canvas,
        PointF currentMouseOffset) {
    if (mOverlayPoint.isVisible())
        drawOnPanning(canvas, currentMouseOffset, mOverlayPoint);

    List<DrawItem> drawItems = mDrawItems;
    for (DrawItem drawItem : drawItems) {
        boolean isSelected = mSelectedItem == drawItem;

        if (mMode != MODE_CHANGE && mMode != MODE_EDIT_BY_TOUCH) {
            drawItem = drawItem.pan(currentMouseOffset);

            if (isSelected) {
                drawItem.setSelectedRing(mSelectedItem.getSelectedRingId());
                drawItem.setSelectedPoint(mSelectedItem.getSelectedPointId());
            }
        }

        drawItem(drawItem, canvas, isSelected);
        if (mLayer != null) {
            int type = mLayer.getGeometryType();
            if (type == GeoConstants.GTPoint || type == GeoConstants.GTMultiPoint) {
                GeoPoint geometry = (GeoPoint) getBaseGeometry(mMap, GeoConstants.GTPoint, mSelectedItem);
                Location last = mGpsEventSource.getLastKnownLocation();
                updateDistance(last, geometry);
            }
        }
    }

    drawCross(canvas);
}
 
Example 5
Source File: GeoGeometryFactory.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 vote down vote up
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 vote down vote up
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 8
Source File: GeoPoint.java    From android_maplib with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public final int getType()
{
    return GeoConstants.GTPoint;
}