static string _doubleFormat = "F6"; // XML precision #endregion Fields #region Methods public static bool WriteCEXML(ref ParcelData parcelData, string xmlFileName, ref Configuration configuration, ESRI.ArcGIS.Client.Geometry.SpatialReference spatialReference, ref PointDictionary pointDictionary, ref MapPoint projectedStartPoint, double scale, double rotation) { DocumentEntry documentType = parcelData.DocumentEntries.CurrentItem as DocumentEntry; ; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineChars = "\r\n"; settings.NewLineHandling = NewLineHandling.Replace; XmlWriter writer = XmlWriter.Create(xmlFileName, settings); if (writer == null) return false; writer.WriteStartDocument(); writer.WriteStartElement("geodata", "GeoSurveyPacketData", @"http://www.geodata.com.au/schemas/GeoSurvey/ESRI/1.0/"); writer.WriteElementString("schemaVersion", "2.0"); WriteUnits(ref writer, ref spatialReference, ref configuration); WriteJobParameters(ref writer, ref configuration); WritePlans(ref writer, ref parcelData, ref pointDictionary, ref projectedStartPoint, scale, rotation, ref configuration, ref documentType); WritePoints(ref writer); WriteControl(ref writer); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Dispose(); // force write of item. return true; }
public MainWindow() { InitializeComponent(); if (License.ShowWindow() != true) { Application.Current.Shutdown(); } else if (!IsNet45OrNewer()) { MessageBox.Show((string)Application.Current.FindResource("strDotNetVersionError"), (string)Application.Current.FindResource("strTitle")); Application.Current.Shutdown(); } else { string statusMessage; _xmlConfiguation = new Configuration(); if (!_xmlConfiguation.ReadConfiguationFile("DeedDrafterConfiguration.xml", out statusMessage)) { MessageBox.Show((string)Application.Current.FindResource("strConfigReadError") + "\n\n" + statusMessage, (string)Application.Current.FindResource("strTitle")); Application.Current.Shutdown(); } else { ConfigureApplication(ref _xmlConfiguation); ResetGrid(); _defaultMapZoomFactor = ParcelMap.ZoomFactor; } } }
// This routine does not write out points, but it does write the start location private static void WriteConstructionData(ref XmlWriter writer, ref ParcelData parcelData, ref PointDictionary pointDictionary, ref MapPoint projectedStartPoint, ref Configuration configuration, ParcelLineRow record) { Int32 pointId = record.GetFrom(); if (!pointDictionary.ContainsKey(pointId)) return; // Rather than using the point from the dictionary, the client should pass in a projected point. // ESRI.ArcGIS.Client.Geometry.MapPoint startPoint = pointDictionary[pointId]; ESRI.ArcGIS.Client.Geometry.MapPoint startPoint = projectedStartPoint; if (startPoint == null) return; writer.WriteStartElement("constructionData"); writer.WriteStartElement("constructionAdjustment"); writer.WriteStartElement("startPoint"); double xM = startPoint.X; double yM = startPoint.Y; if (configuration.HasSpatialReferenceUnit) { xM *= configuration.SpatialReferenceUnitsPerMeter; yM *= configuration.SpatialReferenceUnitsPerMeter; } writer.WriteElementString("unjoinedPointNo", pointId.ToString()); writer.WriteElementString("x", xM.ToString(_doubleFormat)); writer.WriteElementString("y", yM.ToString(_doubleFormat)); writer.WriteEndElement(); // startPoint if (parcelData.CompassRuleApplied) writer.WriteElementString("type", "0"); // compass rule = 0 writer.WriteEndElement(); // constructionAdjustment writer.WriteEndElement(); // constructionData }
public ParcelLineRow(ref Configuration xmlConfig) { _init = true; if (xmlConfig != null) { BearingFormat = xmlConfig.EntryFormat; } _xmlConfig = xmlConfig; }
private static void WriteUnits(ref XmlWriter writer, ref ESRI.ArcGIS.Client.Geometry.SpatialReference spatialReference, ref Configuration configuration) { writer.WriteStartElement("units"); writer.WriteElementString("distanceUnits", GeometryUtil.PacketUnitString(configuration.SpatialReferenceUnitsPerMeter)); writer.WriteElementString("angleUnits", "Degree"); writer.WriteElementString("directionUnits", "Degree"); writer.WriteElementString("directionFormat", "north azimuth"); writer.WriteEndElement(); }
private static void WritePlans(ref XmlWriter writer, ref ParcelData parcelData, ref PointDictionary pointDictionary, ref MapPoint projectedStartPoint, double scale, double rotation, ref Configuration configuration, ref DocumentEntry documentType) { ObservableCollection<ParcelLineRow> parcelRecord = parcelData.GetRecordInfo(); writer.WriteStartElement("plans"); writer.WriteStartElement("plan"); writer.WriteElementString("name", parcelData.PlanName); writer.WriteElementString("description", documentType.Name); writer.WriteElementString("angleUnits", XMLDirectionUnit(parcelData.Configuration.EntryFormat)); writer.WriteElementString("distanceUnits", GeometryUtil.PacketUnitString(configuration.EntryUnitsPerMeter)); writer.WriteElementString("directionFormat", XMLDirectionType(parcelData.Configuration.EntryFormat)); writer.WriteElementString("areaUnits", XMLAreaUnit(parcelData.Configuration.AreaUnit)); writer.WriteElementString("lineParameters", "ChordBearingAndChordLengthAndRadius"); WriteParcel(ref writer, ref parcelData, ref pointDictionary, ref projectedStartPoint, scale, rotation, ref configuration, ref documentType); writer.WriteEndElement(); writer.WriteEndElement(); }
private static void WriteParcel(ref XmlWriter writer, ref ParcelData parcelData, ref PointDictionary pointDictionary, ref MapPoint projectedStartPoint, double scale, double rotation, ref Configuration configuration, ref DocumentEntry documentType) { ObservableCollection<ParcelLineRow> parcelRecord = parcelData.GetRecordInfo(); if (parcelRecord.Count == 0) return; if (rotation < 0) rotation += 360; writer.WriteStartElement("parcels"); writer.WriteStartElement("parcel"); writer.WriteElementString("name", parcelData.ParcelName); if (scale != 1.0) writer.WriteElementString("scale", scale.ToString(_doubleFormat)); if (rotation != 0.0) writer.WriteElementString("rotation", rotation.ToString(_doubleFormat)); string statedArea = "statedArea"; if (parcelData.StatedArea != "") writer.WriteElementString(statedArea, parcelData.StatedArea); else if (parcelData.MiscloseArea > 0) writer.WriteElementString(statedArea, parcelData.MiscloseArea.ToString("F2")); writer.WriteElementString("joined", "false"); writer.WriteElementString("parcelNo", "1"); writer.WriteElementString("type", documentType.Type.ToString()); if ((parcelData.MiscloseDistance != 0.0) && (parcelData.MiscloseBearing != 0.0)) { writer.WriteElementString("miscloseDistance", parcelData.MiscloseDistance.ToString(_doubleFormat)); writer.WriteElementString("miscloseBearing", parcelData.MiscloseBearing.ToString(_doubleFormat)); } // Write document type EA object if (documentType.HasEA) { writer.WriteStartElement("extendedAttributes"); writer.WriteStartElement("extendedAttribute"); writer.WriteElementString("name", documentType.EAField); writer.WriteElementString("value", documentType.EAValue); writer.WriteElementString("type", "VT_BSTR"); writer.WriteEndElement(); writer.WriteEndElement(); } WriteConstructionData(ref writer, ref parcelData, ref pointDictionary, ref projectedStartPoint, ref configuration, parcelRecord[0]); WriteLines(ref writer, ref parcelData, ref documentType, ref configuration); writer.WriteEndElement(); // parcel writer.WriteEndElement(); // parcels }
private static void WriteLines(ref XmlWriter writer, ref ParcelData parcelData, ref DocumentEntry documentType, ref Configuration configuration) { writer.WriteStartElement("lines"); // Write non radial lines ObservableCollection<ParcelLineRow> parcelRecord = parcelData.GetRecordInfo(); Int32 firstId = -1, index = 0, count = 0; foreach (ParcelLineRow record in parcelRecord) if (!IncompleteLine(record)) count++; foreach (ParcelLineRow record in parcelRecord) { if (IncompleteLine(record)) continue; index++; if ((firstId == -1) && (record.Category == LineCategory.Boundary)) firstId = record.GetFrom(); Int32 overrideTo = count == index && count != 1 ? firstId : -1; if (record.Category != LineCategory.Radial) WriteLine(ref writer, record, ref documentType, overrideTo); } // Write radial lines foreach (ParcelLineRow record in parcelRecord) { if (record.CenterPoint == null) continue; ParcelLineRow radialRecord = new ParcelLineRow(ref configuration); radialRecord.From = record.From; radialRecord.To = record.CenterPoint.ToString(); radialRecord.Bearing = GeometryUtil.RadianToDegree(record.RadialBearing1.GetValueOrDefault(0)).ToString(); radialRecord.Distance = record.Radius; radialRecord.Category = LineCategory.Radial; WriteLine(ref writer, radialRecord, ref documentType, -1); radialRecord.From = record.To; radialRecord.Bearing = GeometryUtil.RadianToDegree(record.RadialBearing2.GetValueOrDefault(0)).ToString(); WriteLine(ref writer, radialRecord, ref documentType, -1); } writer.WriteEndElement(); // lines }
private static void WriteJobParameters(ref XmlWriter writer, ref Configuration configuration) { string wkT; if (configuration.OutputSpatialReference != null) // if created via wkId, we don't write SR wkT = configuration.OutputSpatialReference.WKT; else wkT = configuration.SpatialReferenceWKT; // if defined via wkId or missing, we don't write SR if ((wkT == null) || wkT.Length == 0) return; writer.WriteStartElement("jobParameters"); writer.WriteElementString("owner", "DeedDrafter"); writer.WriteElementString("esriSpatialReference", wkT); writer.WriteEndElement(); }
public void IdentifyPoint(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint) { if (config.IdentifyURL == "") return; if (config.IdentifyLayerCount == 0) return; if (config.UseQueryIdentify) { _dataItems = new List<DataItem>(); GeometryService geometryServicePointSnap = new GeometryService(config.GeometryServerUrl); if (geometryServicePointSnap == null) return; QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0); geometryServicePointSnap.BufferCompleted += GeometryService_IdentifyPointBufferCompleted; geometryServicePointSnap.Failed += GeometryService_Failed; geometryServicePointSnap.CancelAsync(); SimpleMarkerSymbol defaultSymbolMarker = new SimpleMarkerSymbol() { Color = System.Windows.Media.Brushes.Black, Size = 8, Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle }; Graphic clickGraphic = new Graphic(); clickGraphic.Symbol = defaultSymbolMarker as ESRI.ArcGIS.Client.Symbols.Symbol; clickGraphic.Geometry = clickPoint; // Input spatial reference for buffer operation defined by first feature of input geometry array clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference; // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters() { BufferSpatialReference = ParcelMap.SpatialReference, OutSpatialReference = ParcelMap.SpatialReference, Unit = LinearUnit.Meter, }; bufferParams.Distances.Add(config.SnapTolerance * config.SpatialReferenceUnitsPerMeter); bufferParams.Features.Add(clickGraphic); geometryServicePointSnap.BufferAsync(bufferParams, queryItem); } else { ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters() { Geometry = clickPoint, MapExtent = ParcelMap.Extent, Width = (int)ParcelMap.ActualWidth, Height = (int)ParcelMap.ActualHeight, LayerOption = LayerOption.visible, SpatialReference = ParcelMap.SpatialReference }; // For performance, we allow certain layers to be only identified. if (config.IdentifyLayerIDs != null) foreach (int id in config.IdentifyLayerIDs) identifyParams.LayerIds.Add(id); IdentifyTask identifyTask = new IdentifyTask(config.IdentifyURL); identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted; identifyTask.Failed += IdentifyTask_Failed; QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0); identifyTask.ExecuteAsync(identifyParams, queryItem); } }
public QueryItem(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint, int index) { // TODO: Complete member initialization _parcelMap = ParcelMap; _config = config; _clickPoint = clickPoint; _index = index; }
private void ConfigureApplication(ref Configuration xmlConfiguation) { Title = xmlConfiguation.Title; Width = xmlConfiguation.Width; Height = xmlConfiguation.Height; ParcelLines.MaxHeight = _xmlConfiguation.MaxGridHeight; // insert layer before [graphical] layers defined in xaml Int32 layerIndex = 0; String lastUnit = ""; foreach (LayerDefinition definition in xmlConfiguation.DisplayLayers) { if (definition.Type == "dynamic") { ArcGISDynamicMapServiceLayer dynamicMS = new ArcGISDynamicMapServiceLayer(); dynamicMS.Url = definition.Url; dynamicMS.ID = definition.Id; dynamicMS.InitializationFailed += Layer_InitializationFailed; ParcelMap.Layers.Insert(layerIndex++, dynamicMS); if ((dynamicMS.Units != null) && (dynamicMS.Units != "") && !xmlConfiguation.HasSpatialReferenceUnit) lastUnit = dynamicMS.Units; } if (definition.Type == "feature") { FeatureLayer featureMS = new FeatureLayer(); featureMS.Url = definition.Url + "/" + definition.Id.ToString(); featureMS.ID = definition.Id; featureMS.InitializationFailed += Layer_InitializationFailed; featureMS.Mode = FeatureLayer.QueryMode.OnDemand; ParcelMap.Layers.Insert(layerIndex++, featureMS); // FOOBAR FeatureLayer does not support unit? } if (definition.Type == "tiled") { ArcGISTiledMapServiceLayer tiledMS = new ArcGISTiledMapServiceLayer(); tiledMS.Url = definition.Url; tiledMS.ID = definition.Id; tiledMS.InitializationFailed += Layer_InitializationFailed; ParcelMap.Layers.Insert(layerIndex++, tiledMS); if ((tiledMS.Units != null) && (tiledMS.Units != "") && !xmlConfiguation.HasSpatialReferenceUnit) lastUnit = tiledMS.Units; } if (definition.Type == "image") { ArcGISImageServiceLayer imageS = new ArcGISImageServiceLayer(); imageS.Url = definition.Url; imageS.ID = definition.Id; imageS.InitializationFailed += Layer_InitializationFailed; ParcelMap.Layers.Insert(layerIndex++, imageS); } } if (!xmlConfiguation.HasSpatialReferenceUnit) xmlConfiguation.MapSpatialReferenceUnits = lastUnit; ESRI.ArcGIS.Client.Geometry.Envelope extent = null; if (xmlConfiguation.IsExtentSet()) extent = new ESRI.ArcGIS.Client.Geometry.Envelope(xmlConfiguation.XMin, xmlConfiguation.YMin, xmlConfiguation.XMax, xmlConfiguation.YMax); else // Map will not zoom to, etc with out some value set. // Ideally we would like to set the extent to the full extent of the first // layer, but since they layer has hot been drawn yet null is returned. extent = new ESRI.ArcGIS.Client.Geometry.Envelope(100, 100, 100, 100); // if zero, the first inserted layer is used if ((xmlConfiguation.SpatialReferenceWKT != null) && (xmlConfiguation.SpatialReferenceWKT != "")) extent.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(xmlConfiguation.SpatialReferenceWKT); else if (xmlConfiguation.SpatialReferenceWKID != 0) extent.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(xmlConfiguation.SpatialReferenceWKID); ParcelMap.Extent = extent; ParcelData parcelData = ParcelGridContainer.DataContext as ParcelData; parcelData.Configuration = xmlConfiguation; QueryLabel.Text = xmlConfiguation.QueryLabel; }