本文整理汇总了Java中com.nextgis.maplib.datasource.GeoPolygon类的典型用法代码示例。如果您正苦于以下问题:Java GeoPolygon类的具体用法?Java GeoPolygon怎么用?Java GeoPolygon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeoPolygon类属于com.nextgis.maplib.datasource包,在下文中一共展示了GeoPolygon类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDraw
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
@Override
public void onDraw(GeoGeometry geoGeometry, GISDisplay display) {
Float scaledTextSize = (null == mTextSize) ? null : (float) (mTextSize / 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");
}
}
示例2: drawPolygon
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
public void drawPolygon(GeoPolygon polygon, GISDisplay display) {
float scaledWidth = (float) (mWidth / display.getScale());
Paint lnPaint = new Paint();
lnPaint.setColor(mOutColor);
lnPaint.setStrokeWidth(scaledWidth);
lnPaint.setStrokeCap(Paint.Cap.ROUND);
lnPaint.setAntiAlias(true);
Path polygonPath = getPath(polygon);
lnPaint.setStyle(Paint.Style.STROKE);
lnPaint.setAlpha(mOuterAlpha);
display.drawPath(polygonPath, lnPaint);
if (mFill) {
lnPaint.setStyle(Paint.Style.FILL);
lnPaint.setColor(mColor);
lnPaint.setAlpha(mInnerAlpha);
display.drawPath(polygonPath, lnPaint);
}
}
示例3: drawPolygon
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
public void drawPolygon(GeoPolygon polygon, GISDisplay display) {
Paint lnPaint = new Paint();
lnPaint.setColor(mColor);
lnPaint.setStrokeWidth((float) (mWidth / display.getScale()));
lnPaint.setStrokeCap(Paint.Cap.ROUND);
lnPaint.setAntiAlias(true);
Path polygonPath = getPath(polygon);
lnPaint.setStyle(Paint.Style.STROKE);
lnPaint.setAlpha(mOuterAlpha);
display.drawPath(polygonPath, lnPaint);
if (mFill) {
lnPaint.setStyle(Paint.Style.FILL);
lnPaint.setAlpha(mInnerAlpha);
lnPaint.setStrokeWidth(0);
display.drawPath(polygonPath, lnPaint);
}
}
示例4: startGeometryByWalk
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
protected void startGeometryByWalk() {
// register broadcast events
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WalkEditService.WALKEDIT_CHANGE);
mReceiver = new WalkEditReceiver();
mContext.registerReceiver(mReceiver, intentFilter);
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());
mContext.startService(trackerService);
}
示例5: fillDrawPolygon
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
protected void fillDrawPolygon(GeoPolygon polygon) {
mSelectedItem = new DrawItem();
fillDrawRing(polygon.getOuterRing());
for (int i = 0; i < polygon.getInnerRingCount(); i++)
fillDrawRing(polygon.getInnerRing(i));
mDrawItems.add(mSelectedItem);
}
示例6: setGeometryFromWalkEdit
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
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;
}
}
示例7: getPath
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
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;
}
示例8: onDraw
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
@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;
}
}
示例9: isGeometryIntersects
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
public static boolean isGeometryIntersects(Context context, GeoGeometry geometry) {
if (geometry instanceof GeoPolygon) {
if (((GeoPolygon) geometry).intersects()) {
Toast.makeText(context, R.string.self_intersection, Toast.LENGTH_SHORT).show();
return true;
}
if (!((GeoPolygon) geometry).isHolesInside()) {
Toast.makeText(context, R.string.ring_outside, Toast.LENGTH_SHORT).show();
return true;
}
if (((GeoPolygon) geometry).isHolesIntersect()) {
Toast.makeText(context, R.string.rings_intersection, Toast.LENGTH_SHORT).show();
return true;
}
}
if (geometry instanceof GeoMultiPolygon) {
if (((GeoMultiPolygon) geometry).isSelfIntersects()) {
Toast.makeText(context, R.string.self_intersection, Toast.LENGTH_SHORT).show();
return true;
}
if (!((GeoMultiPolygon) geometry).isHolesInside()) {
Toast.makeText(context, R.string.ring_outside, Toast.LENGTH_SHORT).show();
return true;
}
if (((GeoMultiPolygon) geometry).isHolesIntersect()) {
Toast.makeText(context, R.string.rings_intersection, Toast.LENGTH_SHORT).show();
return true;
}
}
return false;
}
示例10: fillDrawItems
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
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];
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);
}
}
示例11: convexHull
import com.nextgis.maplib.datasource.GeoPolygon; //导入依赖的package包/类
public static GeoPolygon convexHull(List<GeoPoint> points){
List<GeoPoint> sortedPoints = new ArrayList<>(points);
Collections.sort(sortedPoints, new GeoPointsCompare());
int n = sortedPoints.size();
GeoPoint[] lUpper = new GeoPoint[n];
lUpper[0] = sortedPoints.get(0);
lUpper[1] = sortedPoints.get(1);
int lUpperSize = 2;
for (int i = 2; i < n; i++)
{
lUpper[lUpperSize] = sortedPoints.get(i);
lUpperSize++;
while (lUpperSize > 2 && !rightTurn(lUpper[lUpperSize - 3], lUpper[lUpperSize - 2], lUpper[lUpperSize - 1]))
{
// Remove the middle point of the three last
lUpper[lUpperSize - 2] = lUpper[lUpperSize - 1];
lUpperSize--;
}
}
GeoPoint[] lLower = new GeoPoint[n];
lLower[0] = sortedPoints.get(n - 1);
lLower[1] = sortedPoints.get(n - 2);
int lLowerSize = 2;
for (int i = n - 3; i >= 0; i--)
{
lLower[lLowerSize] = sortedPoints.get(i);
lLowerSize++;
while (lLowerSize > 2 && !rightTurn(lLower[lLowerSize - 3], lLower[lLowerSize - 2], lLower[lLowerSize - 1]))
{
// Remove the middle point of the three last
lLower[lLowerSize - 2] = lLower[lLowerSize - 1];
lLowerSize--;
}
}
GeoPolygon polygon = new GeoPolygon();
for (int i = 0; i < lUpperSize; i++)
{
polygon.add(lUpper[i]);
}
for (int i = 1; i < lLowerSize - 1; i++)
{
polygon.add(lLower[i]);
}
return polygon;
}