Пример #1
0
 public void getPrecintsData(ParcelModel parcel)
 {
     parcel.precints = properties.precints.Where((precint) =>
     {
         object precintShape;
         precint.precint.TryGetValue("Shape", out precintShape);
         object parcelShape;
         parcel.parcel.TryGetValue("Shape", out parcelShape);
         ArcGIS.Core.Geometry.Polygon precintPolygon = (ArcGIS.Core.Geometry.Polygon)precintShape;
         ArcGIS.Core.Geometry.Polygon parcelPolygon  = (ArcGIS.Core.Geometry.Polygon)parcelShape;
         ArcGIS.Core.Geometry.Geometry geometry      = GeometryEngine.Instance.Intersection(precintPolygon, parcelPolygon, GeometryDimension.esriGeometry2Dimension);
         return(!geometry.IsEmpty);
     }).ToList();
 }
Пример #2
0
 public void getResolutionData(ParcelModel parcel)
 {
     parcel.resolutions = properties.resolutions.Where((resolution) =>
     {
         object resolutionShape;
         resolution.resolution.TryGetValue("Shape", out resolutionShape);
         object parcelShape;
         parcel.parcel.TryGetValue("Shape", out parcelShape);
         ArcGIS.Core.Geometry.Polygon resolutionPolygon = (ArcGIS.Core.Geometry.Polygon)resolutionShape;
         ArcGIS.Core.Geometry.Polygon parcelPolygon     = (ArcGIS.Core.Geometry.Polygon)parcelShape;
         ArcGIS.Core.Geometry.Geometry geometry         = GeometryEngine.Instance.Intersection(resolutionPolygon, parcelPolygon, GeometryDimension.esriGeometry2Dimension);
         return(!geometry.IsEmpty);
     }).ToList();
 }
Пример #3
0
 public void addResolutionsToParcel(ParcelModel currentParcel)
 {
     Task t = QueuedTask.Run(() =>
     {
         var models = propertiesAccepted.resolutions.Where((resolution) =>
         {
             object resolutionShape;
             resolution.resolution.TryGetValue("Shape", out resolutionShape);
             object parcelShape;
             currentParcel.parcel.TryGetValue("Shape", out parcelShape);
             ArcGIS.Core.Geometry.Polygon resolutionPolygon = (ArcGIS.Core.Geometry.Polygon)resolutionShape;
             ArcGIS.Core.Geometry.Polygon parcelPolygon     = (ArcGIS.Core.Geometry.Polygon)parcelShape;
             ArcGIS.Core.Geometry.Geometry geometry         = GeometryEngine.Instance.Intersection(resolutionPolygon, parcelPolygon, GeometryDimension.esriGeometry2Dimension);
             return(!geometry.IsEmpty);
         }).ToList();
         currentParcel.resolutions = models;
     });
 }
        public void generateDocument(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!checkData())
                {
                    return;
                }
                this.basicInfos.receiveDate = DateTime.Parse(this.receiveDate.Text);
                if (this.basicInfos.receiveDate > this.basicInfos.date)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Data otrzymania powinna być mniejsza od daty utworzenia");
                    return;
                }
                if (this.basicInfos.receiveDate > DateTime.Now)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Data otrzymania powinna być mniejsza od dzisiejszej daty");
                    return;
                }
                Stream myStream;
                if ((myStream = showWindow("Zapisz wypis i wyrys", "Rich text document format (*.rtf)|*.rtf")) != null)
                {
                    List <MapPoint> points = new List <MapPoint>();
                    foreach (ParcelModel parcel in acceptedProperties.parcels)
                    {
                        object result = null;
                        parcel.parcel.TryGetValue("Shape", out result);
                        foreach (MapPoint point in ((ArcGIS.Core.Geometry.Polygon)result).Points)
                        {
                            points.Add(point);
                        }
                    }
                    Task t = QueuedTask.Run(() =>
                    {
                        string scale;

                        if ((scale = config.getConfig("scale", null)) != null)
                        {
                            Camera camera = MapView.Active.Camera;
                            camera.Scale  = Convert.ToDouble(scale);
                            ArcGIS.Core.Geometry.Polygon polygon = PolygonBuilder.CreatePolygon(points);
                            MapPoint center = polygon.Extent.Center;
                            camera.X        = center.X;
                            camera.Y        = center.Y;
                            MapView.Active.ZoomTo(camera);
                        }
                        else
                        {
                            MapView.Active.ZoomToSelected();
                        }
                    });
                    t.Wait();

                    string buffer     = File.ReadAllText("document.rtf");
                    string editedFile = editDocument(buffer);
                    string footer     = File.ReadAllText("documentFooter.rtf");
                    footer     = this.createFooter(footer);
                    editedFile = appendFooter(footer + "\\par{", editedFile);

                    if (editedFile != null && editedFile.Length > 0)
                    {
                        System.Windows.Forms.RichTextBox rtf = new System.Windows.Forms.RichTextBox();
                        myStream.Write(Encoding.ASCII.GetBytes(editedFile), 0, editedFile.Length);
                        myStream.Close();
                        goBackToMPZP();
                    }
                }
            }
            catch (FileNotFoundException)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Wystąpił błąd. Brakuje pliku z wzorem dokumentu. Wygeneruj taki zgodnie z dokumentacją i podaj ścieżkę do niego w ustawieniach.");
            }
            catch (PathTooLongException)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Zbyt długa ścieżka. Popraw ją i spróbuj ponownie.");
            }
            catch (Exception)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Wystąpił niezidentyfikowany błąd. Sprawdź czy masz odpowiednią ilość miejsca na dysku i czy oznaczenia zgadzają się z tymi w dokumentacji.");
            }
        }
        public string editDocument(string file)
        {
            file = editHeader(file);
            file = getParcelsData(file);
            file = getResolutionData(file);
            file = createAssume(file);

            string HEADER_BG         = "\\red212\\green234\\blue255";
            string BG_LIGHT_GRAY     = "\\red232\\green232\\blue232";
            string BG_LIGHTER_GRAY   = "\\red240\\green240\\blue240";
            string paperSizeProps    = "\\paperw11909\\paperh16834";
            string colorTableString  = "{\\colortbl;" + HEADER_BG + ";" + BG_LIGHT_GRAY + ";" + BG_LIGHTER_GRAY + "}";
            string marginsProps      = "\\margl1400\\margr1400\\margt1400\\margb1400";
            string podsumowanieTable = "{";

            podsumowanieTable += "\\trowd\\trrh400 " +
                                 "\\clvertalc\\clcbpat1\\trbrdrb\\cellx4000 " +
                                 "\\clvertalc\\clcbpat1\\trbrdrb\\cellx5000 " +
                                 "\\clvertalc\\clcbpat1\\trbrdrb\\cellx7000 " +
                                 "\\b " + StringUtil.ToRtfString("Nazwa obrębu") + " \\b0\\intbl\\cell " +
                                 "\\b " + StringUtil.ToRtfString("Nr obrębu") + " \\b0\\intbl\\cell " +
                                 "\\b " + StringUtil.ToRtfString("Nr działki") + " \\b0\\intbl\\cell " +
                                 "\\row";
            var i = 0;

            foreach (ParcelModel parcel in acceptedProperties.parcels)
            {
                string rowBg          = (i % 2 == 0) ? "\\clcbpat2" : "\\clcbpat3";
                string parcelsIdField = config.getConfig("Działki", "parcelsId");
                string areaNameField  = config.getConfig("Obręby", "areaName");
                object areaName       = null;
                var    area           = parcel.precints.Where((precint) =>
                {
                    object resultShape = null;
                    precint.precint.TryGetValue("Shape", out resultShape);
                    ArcGIS.Core.Geometry.Polygon polygon = (ArcGIS.Core.Geometry.Polygon)resultShape;
                    parcel.parcel.TryGetValue("Shape", out resultShape);
                    ArcGIS.Core.Geometry.Polygon parcelPolygon = (ArcGIS.Core.Geometry.Polygon)resultShape;
                    return(!GeometryEngine.Instance.Intersection(polygon, parcelPolygon).IsEmpty);
                }).First();
                area.precint.TryGetValue(areaNameField, out areaName);
                object result = null;
                parcel.parcel.TryGetValue(parcelsIdField, out result);
                var array = result.ToString().Split('.');
                podsumowanieTable += "\\trowd\\trrh360 " +
                                     rowBg + "\\clvertalc\\cellx4000 " +
                                     rowBg + "\\clvertalc\\cellx5000 " +
                                     rowBg + "\\clvertalc\\cellx7000 " +
                                     StringUtil.ToRtfString(areaName.ToString()) + " \\intbl\\cell " +
                                     array[1].TrimStart(new Char[] { '0' }) + " \\intbl\\cell " +
                                     array[2] + " \\intbl\\cell " +
                                     "\\row ";
                i++;
            }
            podsumowanieTable += "}";

            file = file.Replace("[[podsumowanie_tabela]]", podsumowanieTable);

            string    legendFieldName = config.getConfig("MPZP", "MPZPLegend");
            MPZPModel mpzp            = acceptedProperties.mpzpModels.First();
            Object    legend          = null;

            mpzp.mpzp.TryGetValue("legend", out legend);
            if (legend != null)
            {
                Object legendSize = null;
                mpzp.mpzp.TryGetValue("legendSize", out legendSize);

                string str = BitConverter.ToString((byte[])legend, 0).Replace("-", string.Empty);

                string rtfImageStr = @"{\pict\pngblip\picw" +
                                     ((System.Drawing.Size)legendSize).Width + @"\pich" + (((System.Drawing.Size)legendSize).Height * 10) +
                                     @"\picwgoal" + (((System.Drawing.Size)legendSize).Width * 10) + @"\pichgoal" + (((System.Drawing.Size)legendSize).Height * 10) +
                                     str + "}";

                while (file.IndexOf("[[legenda_rastrowa]]") != file.LastIndexOf("[[legenda_rastrowa]]"))
                {
                    file = file.Remove(file.LastIndexOf("[[legenda_rastrowa]]"), 20);
                }

                file = file.Replace("[[legenda_rastrowa]]", rtfImageStr);
            }
            file = convertMapToString(file);
            file = removeStrings(file);
            return(file);
        }