Java Code Examples for com.nextgis.maplib.datasource.GeoMultiLineString

The following examples show how to use com.nextgis.maplib.datasource.GeoMultiLineString. These examples are extracted from open source projects. 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
@Override
public void onDraw(GeoGeometry geoGeometry, GISDisplay display) {
    mColor = Color.argb(mInnerAlpha, Color.red(mColor), Color.green(mColor), Color.blue(mColor));
    mOutColor = Color.argb(mOuterAlpha, Color.red(mOutColor), Color.green(mOutColor), Color.blue(mOutColor));

    switch (geoGeometry.getType()) {
        case GTLineString:
            onDraw((GeoLineString) geoGeometry, display);
            break;

        case GTMultiLineString:
            GeoMultiLineString multiLineString = (GeoMultiLineString) geoGeometry;
            for (int i = 0; i < multiLineString.size(); i++) {
                onDraw(multiLineString.get(i), display);
            }
            break;

        //throw new IllegalArgumentException(
        //        "The input geometry type is not support by this style");
    }

}
 
Example 2
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 3
@Override
public void onDraw(GeoGeometry geoGeometry, GISDisplay display) {
    switch (geoGeometry.getType()) {
        case GTPolygon:
            drawPolygon((GeoPolygon) geoGeometry, display);
            break;
        case GTMultiPolygon:
            GeoMultiPolygon multiPolygon = (GeoMultiPolygon) geoGeometry;

            for (int i = 0; i < multiPolygon.size(); i++) {
                drawPolygon(multiPolygon.get(i), display);
            }
            break;
        case GTPoint:
            drawPoint((GeoPoint) geoGeometry, display);
            break;
        case GTMultiPoint:
            GeoMultiPoint multiPoint = (GeoMultiPoint) geoGeometry;
            for (int i = 0; i < multiPoint.size(); i++) {
                drawPoint(multiPoint.get(i), display);
            }
            break;
        case GTLineString:
            drawLineString((GeoLineString) geoGeometry, display);
            break;
        case GTMultiLineString:
            GeoMultiLineString multiLineString = (GeoMultiLineString) geoGeometry;
            for (int i = 0; i < multiLineString.size(); i++) {
                drawLineString(multiLineString.get(i), display);
            }
            break;
    }
}
 
Example 4
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 5
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;
    }
}