public static void Main(string[] args) { if (args.Length != 1) { usage(); } shapefileObj sf_obj = new shapefileObj(args[0], -1); shapeObj s_obj = new shapeObj(-1); for (int i = 0; i < sf_obj.numshapes; i++) { sf_obj.get(i, s_obj); Console.WriteLine("Shape " + i + " has " + s_obj.numlines + " part(s)"); Console.WriteLine("bounds (" + s_obj.bounds.minx + ", " + s_obj.bounds.miny + ") (" + s_obj.bounds.maxx + ", " + s_obj.bounds.maxy + ")"); for (int j = 0; j < s_obj.numlines; j++) { lineObj l_obj = s_obj.get(j); Console.WriteLine("Part " + j + " has " + l_obj.numpoints + " points."); for (int k = 0; k < l_obj.numpoints; k++) { pointObj p_obj = l_obj.get(k); Console.WriteLine(k + ": " + p_obj.x + ", " + p_obj.y); } } } }
private void centerToShapeToolStripMenuItem_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count > 0 && PositionChanged != null) { shapeObj shape = (shapeObj)listView.SelectedItems[0].SubItems[1].Tag; pointObj pos = shape.getCentroid(); PositionChanged(this, pos.x, pos.y); } }
internal static HandleRef getCPtrAndSetReference(pointObj obj, object parent) { if (obj != null) { obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
internal static HandleRef getCPtrAndDisown(pointObj obj, object parent) { if (obj != null) { obj.swigCMemOwn = false; obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
public int set(int i, pointObj p) { int ret = mapscriptPINVOKE.lineObj_set(swigCPtr, i, pointObj.getCPtr(p)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
internal static HandleRef getCPtr(pointObj obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
public double distanceToSegment(pointObj a, pointObj b) { double ret = mapscriptPINVOKE.pointObj_distanceToSegment(swigCPtr, pointObj.getCPtr(a), pointObj.getCPtr(b)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public int addPoint(pointObj point) { int ret = mapscriptPINVOKE.shapefileObj_addPoint(swigCPtr, pointObj.getCPtr(point)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public int queryByPoint(pointObj point, int mode, double buffer) { int ret = mapscriptPINVOKE.mapObj_queryByPoint(swigCPtr, pointObj.getCPtr(point), mode, buffer); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public int setCenter(pointObj center) { int ret = mapscriptPINVOKE.mapObj_setCenter(swigCPtr, pointObj.getCPtr(center)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
/// <summary> /// Adding a preview feature to the layer according to the layer type. This method is used to initialize the preview controls. /// </summary> /// <param name="srcLayer">The source layer the felature should be created in.</param> /// <param name="numvalues">The number of the feature attributes to be created.</param> private void AddSampleFeature(layerObj srcLayer, int numvalues) { if (srcLayer.type == MS_LAYER_TYPE.MS_LAYER_LINE) { using (shapeObj shape = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_LINE)) { // adding a horizontal line sample using (lineObj line = new lineObj()) { using (pointObj point = new pointObj(this.gap, this.Height / 2, 0, 0)) { line.add(point); point.setXY(this.Width - this.gap, this.Height / 2, 0); line.add(point); } shape.add(line); } if (numvalues > 0) shape.initValues(numvalues); srcLayer.addFeature(shape); } } else if (srcLayer.type == MS_LAYER_TYPE.MS_LAYER_POLYGON) { using (shapeObj shape = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_POLYGON)) { // adding a rectangle sample using (lineObj line = new lineObj()) { using (pointObj point = new pointObj(this.gap, this.gap, 0, 0)) { line.add(point); point.setXY(this.Width - this.gap, this.gap, 0); line.add(point); point.setXY(this.Width - this.gap, this.Height - this.gap, 0); line.add(point); point.setXY(this.gap, this.Height - this.gap, 0); line.add(point); point.setXY(this.gap, this.gap, 0); line.add(point); } shape.add(line); } if (numvalues > 0) shape.initValues(numvalues); srcLayer.addFeature(shape); } } else { using (shapeObj shape = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_POINT)) { // adding a point sample using (lineObj line = new lineObj()) { using (pointObj point = new pointObj(this.Width / 2, this.Height / 2, 0, 0)) { line.add(point); } shape.add(line); } if (numvalues > 0) shape.initValues(numvalues); srcLayer.addFeature(shape); } } }
/// <summary> /// Zooming the map by using the specified zoom factor /// </summary> /// <param name="zoomfactor">Zoom factor.</param> public void ZoomOut(double zoomfactor) { if (map != null) { using (pointObj center = new pointObj(map.width / 2, map.height / 2, 0, 0)) { map.zoomScale(zoomfactor * map.scaledenom, center, map.width, map.height, map.extent, null); RaiseZoomChanged(); } this.RefreshView(); } }
/// <summary> /// Recenter the map to the specified pixel coordinate. /// </summary> /// <param name="imgX">X coordinate in the pixel space.</param> /// <param name="imgY">Y coordinate in the pixel space.</param> public void PanTo(int imgX, int imgY) { if (map != null) { using (pointObj imgpoint = new pointObj(imgX, imgY, 0, 0)) { map.zoomPoint(1, imgpoint, map.width, map.height, map.extent, null); RaisePositionChanged(); } this.RefreshView(); } }
private bool TestResult(pointObj pt) { layerObj layer = map.getLayer(0); layer.queryByPoint(map, pt, mapscript.MS_SINGLE, 4); resultCacheObj results = layer.getResults(); layer.Dispose(); return (results != null && results.numresults > 0); }
/// <summary> /// MouseUp event handler of the Map control. Occurs when a mouse button have been released. /// </summary> /// <param name="sender">The source object of this event.</param> /// <param name="e">The event parameters.</param> private void MapControl_MouseUp(object sender, MouseEventArgs e) { forcePan = false; if (inputMode == InputModes.Select) { //pointObj pt = new pointObj(Pixel2MapX(e.X), Pixel2MapY(e.Y), 0, 0); //TestResult(pt); //return; using (pointObj imgpoint = new pointObj(Pixel2MapX(e.X), Pixel2MapY(e.Y), 0, 0)) { ClearResults(); // clear the previous results map.queryByPoint(imgpoint, mapscript.MS_MULTIPLE, 4); SetSelectionMode(true); this.RefreshView(); this.target.RaiseSelectionChanged(this); } return; } if (magnify != 1) { double offsetX = ((double)1 - (double)1 / magnify) * mouseX; double offsetY = ((double)1 - (double)1 / magnify) * mouseY; if (dragging) { dragging = false; dragRect.Width = e.X - dragRect.X; dragRect.Height = e.Y - dragRect.Y; offsetX -= dragRect.Width; offsetY -= dragRect.Height; } this.ZoomRectangle((double)offsetX, (double)offsetY, (double)offsetX + (double)mapImage.Width / magnify, (double)offsetY + (double)mapImage.Height / magnify); return; } if (dragging) { dragging = false; dragRect.Width = e.X - dragRect.X; dragRect.Height = e.Y - dragRect.Y; if (inputMode == InputModes.Pan || e.Button == MouseButtons.Middle) { if (map != null) PanTo(map.width / 2 - dragRect.Width, map.height / 2 - dragRect.Height); return; } if (inputMode == InputModes.ZoomIn) { ZoomRectangle(Math.Min(dragRect.X, dragRect.X + dragRect.Width), Math.Min(dragRect.Y, dragRect.Y + dragRect.Height), Math.Max(dragRect.X, dragRect.X + dragRect.Width), Math.Max(dragRect.Y, dragRect.Y + dragRect.Height)); return; } if (inputMode == InputModes.ZoomOut) { if (map != null) { //Stephane: change behaviour if small drag of point click to zoom out by a factor of 2, like IntraMaps //if (dragRect.Width <= 2) dragRect.Width = 2; //if (dragRect.Height <= 2) dragRect.Height = 2; if (dragRect.Width <= 2 || dragRect.Height <= 2) { ZoomOut(2); } else { using (pointObj center = new pointObj(dragRect.X + dragRect.Width / 2, dragRect.Y + dragRect.Height / 2, 0, 0)) { double zoomfactor = Math.Min((double)map.width / dragRect.Width, (double)map.height / dragRect.Height); map.zoomScale(zoomfactor * map.scaledenom, center, map.width, map.height, map.extent, null); RaiseZoomChanged(); this.RefreshView(); } } } return; } if (inputMode == InputModes.TrackRectangle) { double x = Pixel2MapX(dragRect.X); double y = Pixel2MapY(dragRect.Y); double x2 = Pixel2MapX(dragRect.X + dragRect.Width); double y2 = Pixel2MapY(dragRect.Y + dragRect.Height); using (rectObj rect = new rectObj(Math.Min(x, x2), Math.Min(y, y2), Math.Max(x, x2), Math.Max(y, y2), 0)) { map.queryByRect(rect); SetSelectionMode(true); this.RefreshView(); this.target.RaiseSelectionChanged(this); return; } } this.Refresh(); } }
public int contains(pointObj point) { int ret = mapscriptPINVOKE.shapeObj_contains__SWIG_1(swigCPtr, pointObj.getCPtr(point)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public double distanceToPoint(pointObj point) { double ret = mapscriptPINVOKE.shapeObj_distanceToPoint(swigCPtr, pointObj.getCPtr(point)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public int zoomScale(double scale, pointObj poPixPos, int width, int height, rectObj poGeorefExt, rectObj poMaxGeorefExt) { int ret = mapscriptPINVOKE.mapObj_zoomScale(swigCPtr, scale, pointObj.getCPtr(poPixPos), width, height, rectObj.getCPtr(poGeorefExt), rectObj.getCPtr(poMaxGeorefExt)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }