Exemplo n.º 1
0
        public bool MapGearDistribution(List <GearInventoryMappingItem> distributionList, string gearName, bool doFisherJenks = false)
        {
            Shapefile sf = new Shapefile();

            if (sf.CreateNew("", ShpfileType.SHP_POINT))
            {
                sf.GeoProjection = _mapControl.GeoProjection;
                int ifldProjectName      = sf.EditAddField("Inventory project", FieldType.STRING_FIELD, 1, 50);
                int ifldProvince         = sf.EditAddField("Province", FieldType.STRING_FIELD, 1, 30);
                int ifldMunicipalityName = sf.EditAddField("Municipality", FieldType.STRING_FIELD, 1, 30);
                int ifldMuni             = sf.EditAddField("Muni", FieldType.STRING_FIELD, 1, 8);
                int ifldGear             = sf.EditAddField("Gear", FieldType.STRING_FIELD, 1, 50);
                int ifldX               = sf.EditAddField("x", FieldType.DOUBLE_FIELD, 9, 12);
                int ifldY               = sf.EditAddField("y", FieldType.DOUBLE_FIELD, 9, 12);
                int ifldCount           = sf.EditAddField("n", FieldType.INTEGER_FIELD, 1, 7);
                int ifldCommercial      = sf.EditAddField("Commercial", FieldType.INTEGER_FIELD, 1, 7);
                int ifldMunicipalMot    = sf.EditAddField("Motorized", FieldType.INTEGER_FIELD, 1, 7);
                int ifldMunicipalNonMot = sf.EditAddField("Non-motorized", FieldType.INTEGER_FIELD, 1, 7);
                int ifldNoBoat          = sf.EditAddField("No boat", FieldType.INTEGER_FIELD, 1, 7);
                foreach (var item in distributionList)
                {
                    Shape sh = new Shape();
                    if (sh.Create(ShpfileType.SHP_POINT) && sh.AddPoint(item.X, item.Y) >= 0)
                    {
                        var iShp = sf.EditAddShape(sh);
                        if (iShp >= 0)
                        {
                            sf.EditCellValue(ifldProjectName, iShp, item.InventoryProjectName);
                            sf.EditCellValue(ifldProvince, iShp, item.ProvinceName);
                            sf.EditCellValue(ifldMunicipalityName, iShp, item.Municipality);
                            //sf.EditCellValue(ifldMunNameAbbrev, iShp, item.Municipality.Substring(0, 4));
                            sf.EditCellValue(ifldMuni, iShp, Database.Classes.LGUs.ShortenPlaceName(item.Municipality));
                            sf.EditCellValue(ifldGear, iShp, item.GearVariationName);
                            sf.EditCellValue(ifldX, iShp, item.X);
                            sf.EditCellValue(ifldY, iShp, item.Y);
                            sf.EditCellValue(ifldCount, iShp, item.TotalUsed);
                            sf.EditCellValue(ifldCommercial, iShp, item.CountCommercial);
                            sf.EditCellValue(ifldMunicipalMot, iShp, item.CountMunicipalMotorized);
                            sf.EditCellValue(ifldMunicipalNonMot, iShp, item.CountMunicipalNonMotorized);
                            sf.EditCellValue(ifldNoBoat, iShp, item.CountNoBoat);
                        }
                    }
                }
                sf.DefaultDrawingOptions.PointShape  = tkPointShapeType.ptShapeCircle;
                sf.DefaultDrawingOptions.FillColor   = new Utils().ColorByName(tkMapColor.Blue);
                sf.DefaultDrawingOptions.LineColor   = new Utils().ColorByName(tkMapColor.White);
                sf.DefaultDrawingOptions.LineVisible = true;
                sf.CollisionMode = tkCollisionMode.AllowCollisions;
                Database.Classes.ClassificationType classificationType = Database.Classes.ClassificationType.NaturalBreaks;
                if (ComparisonAmongLGUs)
                {
                    ShapefileLayerHelper.CategorizeNumericPointLayer(sf, ifldCount);
                }
                else
                {
                    ShapefileLayerHelper.CategorizeNumericPointLayer(sf, GearDataFisherJenksBreaks, ifldCount, BreakSourceMaximum);
                    classificationType = Database.Classes.ClassificationType.JenksFisher;
                }
                InventoryLayerHandle = _layersHandler.AddLayer(sf, gearName);
                _layersHandler[InventoryLayerHandle].ClassificationType = classificationType;
                //_layersHandler.set_MapLayer(h);

                if (Labels != null)
                {
                    sf.Labels.Clear();
                    _layersHandler.ShapeFileLableHandler.LabelShapefile(_labelXML);
                }

                _layersHandler.SetAsPointLayerFromDatabase(_layersHandler[InventoryLayerHandle]);
            }
            return(sf.NumShapes > 0);
        }
Exemplo n.º 2
0
        public bool MapFisherBoatDistribution(List <FisherVesselInventoryItem> distributionList, string itemToMap)
        {
            Shapefile sf = new Shapefile();

            if (sf.CreateNew("", ShpfileType.SHP_POINT))
            {
                sf.GeoProjection = _mapControl.GeoProjection;
                int ifldProjectName      = sf.EditAddField("Inventory project", FieldType.STRING_FIELD, 1, 50);
                int ifldProvince         = sf.EditAddField("Province", FieldType.STRING_FIELD, 1, 30);
                int ifldMunicipalityName = sf.EditAddField("Municipality", FieldType.STRING_FIELD, 1, 30);
                int ifldMuni             = sf.EditAddField("Muni", FieldType.STRING_FIELD, 1, 4);
                int ifldX               = sf.EditAddField("x", FieldType.DOUBLE_FIELD, 9, 12);
                int ifldY               = sf.EditAddField("y", FieldType.DOUBLE_FIELD, 9, 12);
                int ifldFishers         = sf.EditAddField("Fishers", FieldType.INTEGER_FIELD, 1, 7);
                int ifldCommercial      = sf.EditAddField("Commercial", FieldType.INTEGER_FIELD, 1, 7);
                int ifldMunicipalMot    = sf.EditAddField("Municipal Motorized", FieldType.INTEGER_FIELD, 1, 7);
                int ifldMunicipalNonMot = sf.EditAddField("Municipal Non-motorized", FieldType.INTEGER_FIELD, 1, 7);
                foreach (var item in distributionList)
                {
                    Shape sh = new Shape();
                    if (sh.Create(ShpfileType.SHP_POINT) && sh.AddPoint(item.X, item.Y) >= 0)
                    {
                        var iShp = sf.EditAddShape(sh);
                        if (iShp >= 0)
                        {
                            sf.EditCellValue(ifldProjectName, iShp, item.InventoryProjectName);
                            sf.EditCellValue(ifldProvince, iShp, item.ProvinceName);
                            sf.EditCellValue(ifldMunicipalityName, iShp, item.Municipality);
                            sf.EditCellValue(ifldMuni, iShp, Database.Classes.LGUs.ShortenPlaceName(item.Municipality));
                            sf.EditCellValue(ifldX, iShp, item.X);
                            sf.EditCellValue(ifldY, iShp, item.Y);
                            sf.EditCellValue(ifldFishers, iShp, item.CountFisher);
                            sf.EditCellValue(ifldCommercial, iShp, item.CountCommercial);
                            sf.EditCellValue(ifldMunicipalMot, iShp, item.CountMunicipalMotorized);
                            sf.EditCellValue(ifldMunicipalNonMot, iShp, item.CountMunicipalNonMotorized);
                        }
                    }
                }
                sf.DefaultDrawingOptions.PointShape  = tkPointShapeType.ptShapeCircle;
                sf.DefaultDrawingOptions.FillColor   = new Utils().ColorByName(tkMapColor.Blue);
                sf.DefaultDrawingOptions.LineColor   = new Utils().ColorByName(tkMapColor.White);
                sf.DefaultDrawingOptions.LineVisible = true;
                sf.CollisionMode = tkCollisionMode.AllowCollisions;

                int    fld      = 0;
                string itemName = "";
                switch (itemToMap)
                {
                case "fishers":
                    itemName = "Total number of fishers";
                    fld      = ifldFishers;
                    break;

                case "commercial":
                    fld      = ifldCommercial;
                    itemName = "Total number of commercial fishing vessels";
                    break;

                case "municipalMotorized":
                    fld      = ifldMunicipalMot;
                    itemName = "Total number of municipal motorized vessels";
                    break;

                case "municipalNonMotorized":
                    fld      = ifldMunicipalNonMot;
                    itemName = "Total number of municipal non-motorized vessels";
                    break;
                }

                Database.Classes.ClassificationType classificationType = Database.Classes.ClassificationType.NaturalBreaks;
                if (itemToMap == "fishers" || ComparisonAmongLGUs)
                {
                    ShapefileLayerHelper.CategorizeNumericPointLayer(sf, fld);
                }
                else
                {
                    ShapefileLayerHelper.CategorizeNumericPointLayer(sf, FisherVesselDataFisherJenksBreaks, fld, BreakSourceMaximum);
                    classificationType = Database.Classes.ClassificationType.JenksFisher;
                }

                InventoryLayerHandle = _layersHandler.AddLayer(sf, itemName);
                _layersHandler[InventoryLayerHandle].IgnoreZeroWhenClassifying = true;
                _layersHandler[InventoryLayerHandle].ClassificationType        = classificationType;

                if (Labels != null)
                {
                    sf.Labels.Clear();
                    _layersHandler.ShapeFileLableHandler.LabelShapefile(_labelXML);
                }
                _layersHandler.SetAsPointLayerFromDatabase(_layersHandler[InventoryLayerHandle]);
            }
            return(sf.NumShapes > 0);
        }