def polygon(x, y = None): ''' Create polygon from coordinate data. :param x: (*array_like*) X coordinate array. If y is ``None``, x should be 2-D array contains x and y. :param y: (*array_like*) Y coordinate array. :returns: (*PolygonShape*) Created polygon. ''' if y is None: polygon = ShapeUtil.createPolygonShape(x) else: if isinstance(x, MIArray): x = x.aslist() if isinstance(y, MIArray): y = y.aslist() polygon = ShapeUtil.createPolygonShape(x, y) return polygon
def makeshapes(x, y, type=None, z=None, m=None): """ Make shapes by x and y coordinates. :param x: (*array_like*) X coordinates. :param y: (*array_like*) Y coordinates. :param type: (*string*) Shape type [point | line | polygon]. :param z: (*array_like*) Z coordinates. :param m: (*array_like*) M coordinates. :returns: Shapes """ shapes = [] if isinstance(x, (int, float)): shape = PointShape() shape.setPoint(PointD(x, y)) shapes.append(shape) else: x = minum.asarray(x).array y = minum.asarray(y).array if not z is None: if m is None: m = minum.zeros(len(z)).array else: m = minum.asarray(m) z = minum.asarray(z) if type == 'point': if z is None: shapes = ShapeUtil.createPointShapes(x, y) else: shapes = ShapeUtil.createPointShapes(x, y, z, m) elif type == 'line': if z is None: shapes = ShapeUtil.createPolylineShapes(x, y) else: shapes = ShapeUtil.createPolylineShapes(x, y, z, m) elif type == 'polygon': if z is None: shapes = ShapeUtil.createPolygonShapes(x, y) else: shapes = ShapeUtil.createPolygonShape(x, y, z, m) return shapes
def makeshapes(x, y, type=None, z=None, m=None): """ Make shapes by x and y coordinates. :param x: (*array_like*) X coordinates. :param y: (*array_like*) Y coordinates. :param type: (*string*) Shape type [point | line | polygon]. :param z: (*array_like*) Z coordinates. :param m: (*array_like*) M coordinates. :returns: Shapes """ shapes = [] if isinstance(x, (int, float)): shape = PointShape() shape.setPoint(PointD(x, y)) shapes.append(shape) else: x = minum.asarray(x).array y = minum.asarray(y).array if not z is None: if m is None: m = minum.zeros(len(z)).array else: m = minum.asarray(m).array z = minum.asarray(z).array if type == 'point': if z is None: shapes = ShapeUtil.createPointShapes(x, y) else: shapes = ShapeUtil.createPointShapes(x, y, z, m) elif type == 'line': if z is None: shapes = ShapeUtil.createPolylineShapes(x, y) else: shapes = ShapeUtil.createPolylineShapes(x, y, z, m) elif type == 'polygon': if z is None: shapes = ShapeUtil.createPolygonShapes(x, y) else: shapes = ShapeUtil.createPolygonShape(x, y, z, m) return shapes