using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.WebEdition; using System.Collections.ObjectModel; using System.Text; using System.Text.RegularExpressions; using RapidExtract.VO; using RapidExtract.DAL; using System.Drawing; namespace RapidExtract.UI { public partial class ZoneMap : System.Web.UI.Page { public Collection Features { get; set; } public Collection FeaturesStruct { get; set; } public Collection AllFeatures { get; set; } Collection LayerFeature = new Collection(); Collection adjacentFeatures1 { get; set; } RectangleShape shp = new RectangleShape(); GeoCanvas canvas; Feature f1; PointShape XcYc, XnwYnw, XY, XYn, XnY, XnYn; string ID = "PIN";//"CTS_NO",ID; // static string [] strIDs // int Id1; static string CStxt_ID; static string CS_No; static int App_ID; static string Village; static string Tahasil; static string SurveyNo; DataSet path = new DataSet(); string tahasil = string.Empty; string CTSFile = string.Empty; string STRFile = string.Empty; string RoadFile = string.Empty; private MapEngine mapEngine = new MapEngine(); private Bitmap bitmap = null; public static ShapeFileFeatureLayer worldLayer = null; public static InMemoryFeatureLayer mapShapeLayer = null; public static LayerOverlay staticOverlay = new LayerOverlay(); public static LayerOverlay dynamicOverlay = new LayerOverlay(); ShapeFileFeatureLayer evergreenLayer = null; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Panel1.Visible = false; // //Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));//(GeoColor.StandardColors.SlateGray); // Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White); // Map1.CurrentExtent = new RectangleShape(-125, 72, 50, -46); //For GeographyUnit.DecimalDegree Unit // Map1.MapUnit = GeographyUnit.DecimalDegree; // //Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962); // //Map1.CurrentExtent = new RectangleShape(-19268509.29874, 13535292.38285, 20656089.34576, -14435365.7673); // // Map1.CurrentExtent = new RectangleShape(-5E-06, 5E-06, 5E-06, -5E-06); //Default RectangleShape // //Image1.Visible = false; // //To restrict ZoonIn,ZoomOut disable Pan // Map1.MapTools.MouseMapTool.IsMouseWheelDisabled = true; // Map1.MapTools.PanZoomBar.Enabled = false; // //To disable double click // Map1.MapTools.MouseMapTool.Enabled = false; // //Image1.Visible = false; // //createMapStructure(); // //if (Request.QueryString["ParcelID"] != null) // //{ // CStxt_ID = "32";//Request.QueryString["ParcelID"]; //// } // //btnSet.Attributes.Add("OnClick", "IsValid('frmParcelIdentification')"); //// lblError.Text = ""; // if (CStxt_ID != "0") // { // GetMapDetails(CStxt_ID); // //GetMapStructure(); // } // else // { // //DisplayErrorMessage("0 is not a valid Cadastral Survey No."); // } // //Session["menuVisit"] = "0"; // //if (Request.QueryString["AppID"] != null) // // App_ID = int.Parse(Request.QueryString["AppID"]); // //drpScale.SelectedValue = "1cm : 5m"; // //drpSize.SelectedValue = "A4"; // //lblMapScale1.Text = "1cm : 5m"; // //tbl1.Visible = false; // //tbl2.Visible = false; // //trNt.Visible = false; // //trNtlbl.Visible = false; // //trbott.Visible = false; // //ApplicationManager obj = new ApplicationManager(); // //DataSet dsRandomCode = new DataSet(); // //dsRandomCode = obj.GetRandomCode("A",App_ID,0); // //lblRandomCode.Text = dsRandomCode.Tables[0].Rows[0][3].ToString(); } } protected void GetMapDetails( string CS_No) { try { //if (Request.QueryString["AppID"] != null) //{ // AuthorisationManager obj = new AuthorisationManager(); // path = obj.GetFilePath(int.Parse(Request.QueryString["AppID"])); //} //Collections Feature Layerfeature = new Feature(); if (CS_No == "7" || CS_No == "20" || CS_No == "18") { clipping(CS_No); } else { GetTahasil(); //Code to get CS_No wise Area if (!string.IsNullOrEmpty(CS_No)) { //ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Get.RootFilePath + path.Tables[0].Rows[0]["Path"].ToString()); //ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer("D:\\Projects\\RapidExtract\\Documents\\mumbai Division\\Coloba\\Shapefile\\Colaba_CTS_Close_Boundary_With_Sheet_Nos.shp"); // worldLayer = new ShapeFileFeatureLayer("C:/MumbaiDivision/" + tahasil + "/" + CTSFile); worldLayer = new ShapeFileFeatureLayer("C:/PMRDA/" + tahasil + "/" + Village + "/" + CTSFile); // @"C:\MumbaiDivision\Narhe\Sampl04.shp worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.StandardColors.Black); // GeoColor.FromArgb(100, GeoColor.SimpleColors.Black)); worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //To Apply Dash Line Style //worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.DashStyle = LineDashStyle.Dash; //DrawingFeatures event to display only Selected Area based on ID & restrict other Features from drawing worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add(ID); // worldLayer.DrawingFeatures += new EventHandler(worldLayer_DrawingFeatures); worldLayer.RequireIndex = false; //if (string.IsNullOrEmpty(txtWd.Text)) // txtWd.Text = "20"; //else // txtWd.Text = txtWd.Text; //if (string.IsNullOrEmpty(txtGap.Text)) // txtGap.Text = "5"; //else // txtGap.Text = txtGap.Text; ////To Apply Custom LineStyles //LineStyle ls = new LineStyle(); //GeoPen OuterPen = worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen; //new GeoPen(new GeoColor(255, GeoColor.SimpleColors.Black), 3); //OuterPen.DashPattern.Add(int.Parse(txtWd.Text.ToString()));// To set width of Line shape //OuterPen.DashPattern.Add(int.Parse(txtGap.Text.ToString()));//To set gap between //ls.OuterPen = OuterPen; /* //To Apply Custom LineStyle LineStyle ls = new LineStyle(); GeoPen OuterPen = worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen; //new GeoPen(new GeoColor(255, GeoColor.SimpleColors.Black), 3); OuterPen.DashPattern.Add(15);// To set width of Line shape OuterPen.DashPattern.Add(5);//To set gap between ls.OuterPen = OuterPen;*/ Map1.ZoomLevelSet.ZoomLevel01.Scale = 927; //1044 //To Display ID of each parcel/area //worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle(ID, new GeoFont("Arial", 8), new GeoSolidBrush(GeoColor.StandardColors.Black)); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(ID, "Arial", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.PointPlacement = PointPlacement.Center; worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping; worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.DuplicateRule = LabelDuplicateRule.OneDuplicateLabelPerQuadrant; //To create .idx file ShapeFileFeatureSource.BuildIndexFile(worldLayer.ShapePathFileName); mapShapeLayer = new InMemoryFeatureLayer(); mapShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; staticOverlay.Layers.Add("WorldLayer", worldLayer); staticOverlay.IsBaseOverlay = false; dynamicOverlay.Layers.Add("InMemoryFeatureLayer", mapShapeLayer); dynamicOverlay.IsBaseOverlay = false; Map1.CustomOverlays.Add(staticOverlay); Map1.CustomOverlays.Add(dynamicOverlay); FeatureLayer shapeFileLayer = (FeatureLayer)((LayerOverlay)Map1.CustomOverlays[0]).Layers["WorldLayer"]; // FeatureLayer shapeFileLayer = (FeatureLayer)((LayerOverlay)Map1.CustomOverlays[0]).Layers["WorldLayer"]; //To add scale to MAP //ScaleLineAdornmentLayer scaleLineAdornmentLayer = new ScaleLineAdornmentLayer(); //Map1.AdornmentOverlay.Layers.Add("ScaleLineAdornmentLayer", scaleLineAdornmentLayer); //Map1.MapTools.ScaleLine.Enabled = true; //if (Map1.AdornmentOverlay.Layers.Count == 0) //{ // //To set North direction and its Rotation Angle. North- 0,West- 90,South- 180,East- 270 // string NorthImg1 = HttpContext.Current.Server.MapPath("/RapidExtractApplication/IMG/north1.PNG");//compass_needle_letters_disc.PNG"); // //string NorthImg = ("~/IMG/NorthImg2.png"); // GeoImage needleImage = new GeoImage(NorthImg1); // //string NorthImg1 = HttpContext.Current.Server.MapPath("/Images/compass_circle_digits.PNG"); // //GeoImage frameImage = new GeoImage(NorthImg1); // CompassAdornmentLayer compassAdornmentLayer = new CompassAdornmentLayer(needleImage, Position.UpperRight, 70); // RotationProjection rotation = new RotationProjection(); // //rotation = (RotationProjection)((FeatureLayer)Map1.StaticOverlay.Layers[0]).FeatureSource.Projection; // rotation = (RotationProjection)shapeFileLayer.FeatureSource.Projection; // //compassAdornmentLayer.RotateAngle = (float)rotation.Angle; // Map1.AdornmentOverlay.Layers.Add("CompassLayer", compassAdornmentLayer); //} //RotationProjection rotation1 = new RotationProjection(); ////rotation1 = (RotationProjection)((FeatureLayer)Map1.StaticOverlay.Layers[0]).FeatureSource.Projection; ////float angle = (float)rotation1.Angle; //Image1.Visible = true; /*string NorthImg = HttpContext.Current.Server.MapPath("/RapidExtractApplication/IMG/north4.PNG"); //NorthImg2 System.Drawing.Image myImg = System.Drawing.Image.FromFile(NorthImg); Bitmap Bmap = RotateBitmap(0,(Bitmap)myImg); if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/IMG/" + "NorthImage"))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/IMG/" + "NorthImage")); } string outPath = HttpContext.Current.Server.MapPath("~/IMG/" + "NorthImage") + @"/" + "north4.png"; //NorthArrow Bmap.Save(outPath); Bmap.Dispose();*/ /*Bitmap CBmap = RotateBitmap(0, (Bitmap)myImg); if (!Directory.Exists("C:/inetpub/wwwroot/RapidExtractApplication/NorthImage")) { Directory.CreateDirectory("C:/inetpub/wwwroot/RapidExtractApplication/" + "NorthImage"); } string MainPath = "C:/inetpub/wwwroot/RapidExtractApplication/NorthImage/NorthArrow.png"; CBmap.Save(MainPath); CBmap.Dispose();*/ #region Code to Display Adjacent Area's CS No. on selected area of type Line InMemoryFeatureLayer mapShapeLayer1 = (InMemoryFeatureLayer)((LayerOverlay)Map1.CustomOverlays[1]).Layers["InMemoryFeatureLayer"]; mapShapeLayer1.Open(); mapShapeLayer1.Columns.Add(new FeatureSourceColumn("Length")); mapShapeLayer1.Close(); LayerOverlay inMemoryOverlay = new LayerOverlay(); inMemoryOverlay.Layers.Add("InMemoryLayer", mapShapeLayer1); Map1.CustomOverlays.Add(inMemoryOverlay); //Adjacent Layer InMemoryFeatureLayer adjacentLayer = new InMemoryFeatureLayer(); //adjacentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black)); //adjacentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay adjacentOverlay = new LayerOverlay(); adjacentOverlay.Layers.Add("AdjacentLayer", adjacentLayer); Map1.CustomOverlays.Add(adjacentOverlay); InMemoryFeatureLayer inMemoryLayer1 = (InMemoryFeatureLayer)((LayerOverlay)Map1.CustomOverlays[2]).Layers["InMemoryLayer"]; inMemoryLayer1.InternalFeatures.Clear(); InMemoryFeatureLayer adjacentFeatureLayer = (InMemoryFeatureLayer)((LayerOverlay)Map1.CustomOverlays[3]).Layers["AdjacentLayer"]; adjacentFeatureLayer.InternalFeatures.Clear(); string[] strIDs = CS_No.Split(','); // string[] strIDs=CStxt_ID.TrimEnd(','); // strIDs[0] = "7A"; //strIDs[1] = "7B"; //shapeFileLayer.Open(); //LayerFeature = shapeFileLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); chanege byprajakta2015_09_09 //shapeFileLayer.Close(); for (int a = 0; a < strIDs.Length; a++) { if (strIDs[a] != "0") { shapeFileLayer.Open(); // worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add(strIDs[a]); Features = shapeFileLayer.QueryTools.GetFeaturesByColumnValue(ID, strIDs[a]); //To show Multiple Parcels mapShapeLayer.InternalFeatures.Add(Features[0]); Feature polygon = new Feature(); foreach (Feature feature in Features) { if (feature.ColumnValues[ID].ToString() == strIDs[a]) { polygon = feature; } } //To Highlight AdjacentFeatures of TargetFeature Feature f2 = null; Feature f3 = null; MultipolygonShape Shape = (MultipolygonShape)polygon.GetShape(); double area = Convert.ToDouble(Math.Round(Shape.Polygons[0].GetArea(GeographyUnit.Meter, AreaUnit.SquareMeters), 4).ToString()); adjacentFeatures1 = shapeFileLayer.QueryTools.GetFeaturesTouching(polygon, ReturningColumnsType.AllColumns); shapeFileLayer.Close(); adjacentFeatureLayer.Open(); foreach (Feature ff in adjacentFeatures1) { adjacentFeatureLayer.InternalFeatures.Add(ff.Id + a, ff); } adjacentFeatureLayer.Close(); string txt = Shape.Polygons[0].GetWellKnownText(); txt = txt.Replace("POLYGON((", ""); txt = txt.Replace("))", ""); string[] str = txt.Split(','); string[] arr_label = new string[20]; int ii = 0; foreach (Feature ff in adjacentFeatures1) { arr_label[ii] = ff.ColumnValues[ID].ToString(); ii++; } for (int i = 0; i < str.Length; i++) { if (i != 0) { string p1 = str[i - 1].Split(' ')[0] + " " + str[i - 1].Split(' ')[1]; string p2 = str[i].Split(' ')[0] + " " + str[i].Split(' ')[1]; f1 = new Feature(BaseShape.CreateShapeFromWellKnownData("LINESTRING(" + p1 + ", " + p2 + ")")); LineShape line = (LineShape)f1.GetShape(); double len = Math.Round(line.GetLength(GeographyUnit.Meter, DistanceUnit.Meter), 2); int j = 0; string s = string.Empty; bool flag = false; foreach (Feature ff in adjacentFeatures1) { string txt1 = ff.GetWellKnownText(); txt1 = txt1.Replace("MULTIPOLYGON(((", ""); txt1 = txt1.Replace(")))", ""); string[] str1 = txt1.Split(','); for (int k = 0; k < str1.Length; k++) { if (k != 0) { string p11 = str1[k - 1].Split(' ')[0] + " " + str1[k - 1].Split(' ')[1]; string p22 = str1[k].Split(' ')[0] + " " + str1[k].Split(' ')[1]; f2 = new Feature(BaseShape.CreateShapeFromWellKnownData("LINESTRING(" + p11 + ", " + p22 + ")")); f3 = new Feature(BaseShape.CreateShapeFromWellKnownData("LINESTRING(" + p22 + ", " + p11 + ")")); LineShape l2 = (LineShape)f2.GetShape(); LineShape l3 = (LineShape)f3.GetShape(); l2.TranslateByOffset(10, 10); l3.TranslateByOffset(10, 10); if ((p1 == p11 && p2 == p22) || (p2 == p11 && p1 == p22)) { s += ff.ColumnValues[ID].ToString(); flag = true; break; } } } if (flag) break; } //XcYc = line.GetCenterPoint(); if (s.Equals("")) s = "Failed to load adjacent"; f1.ColumnValues.Add("Length", s); // + "(" + ff.Id + ")"); inMemoryLayer1.InternalFeatures.Add(i.ToString(), f1); //string ss = "C.S.No- "; //Adjoining //if (s.Equals("") || s.Equals("0")) //{ // s = ""; // ss = ""; //} //f1.ColumnValues.Add("Length", ss + s); //f1.ColumnValues.Add("Length", s + " (" + len.ToString() + ")"); //To calculate length of each lineString //inMemoryLayer1.InternalFeatures.Add(f1.Id, f1); //i.ToString() //line.TranslateByOffset(10,10); } } //inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("Length", new GeoFont("Arial", 6), new GeoSolidBrush(GeoColor.StandardColors.Black)); //To Set Text Style to do actual labeling.Set xOffset & yOffset to -ve no. to Label below the Feature line //TextStyle myTextStyle = new TextStyle("Length", new GeoFont("Consolas", 10F), new GeoSolidBrush(GeoColor.StandardColors.Black)) //{ // SuppressPartialLabels = true, // OverlappingRule = LabelOverlappingRule.NoOverlapping, // PolygonLabelingLocationMode = ThinkGeo.MapSuite.Core.PolygonLabelingLocationMode.Centroid //}; ////inMemoryLayer1.ZoomLevelSet.GetZoomLevels()[zoomLevelIndex - 1].CustomStyles.Add(myTextStyle); //inMemoryLayer1.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(myTextStyle); //TextStyle myTextStyle = new TextStyle("Length", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.StandardColors.Red)); //myTextStyle.PolygonLabelingLocationMode = PolygonLabelingLocationMode.BoundingBoxCenter; //inMemoryLayer1.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(myTextStyle); inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Length", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Black); // inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Square, GeoColor.StandardColors.Black, 3.5); // setAreaColor(CStxt_ID, inMemoryLayer1);change made by praju on 12_09_2015 // string Layer = LayerFeature[0].ColumnValues["LAYER"]; //setZoneColor(int.Parse(CStxt_ID), Layer, inMemoryLayer1); AllFeatures = Features; #endregion } //txtArea.Text = area1.ToString(); ((LayerOverlay)Map1.CustomOverlays[1]).Redraw(); Map1.CurrentExtent = Features[0].GetBoundingBox(); MapDetailsDAL objMSDAL = new MapDetailsDAL(); // string[] strds = CS_No.Split(','); //for (int a = 0; a < strds.Length; a++) //{ DataSet dsprzone = objMSDAL.GetRP_Zone(strIDs[a]); int rpzone = int.Parse(dsprzone.Tables[0].Rows[0][0].ToString()); Session["rpzone"] = rpzone; DataSet ds = objMSDAL.ColorName(rpzone); string color = ds.Tables[0].Rows[0][0].ToString(); if (!string.IsNullOrEmpty(tahasil)) { if (color == "150") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Green; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "51") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Yellow; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "102,102,255") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Blue; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "179,153,255") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Violet; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "255,128,149") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.LightPink; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "230,115,0") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Orange; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "1191,255,128") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.LightGreen; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "253") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Gray; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "83,198,83") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Green; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "179,153,255") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Green; setAreaColor(strIDs[a], inMemoryLayer1); } else if (color == "131") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.LightBlue; setAreaColor(strIDs[a], inMemoryLayer1); } } // } } //drpScale.SelectedValue = "1:500"; ////lblScale.Text = "SCALE - 1cm = 5m"; ////Map1.Controls.AddAt(0, lblMapScale); //lblMapScale1.Text = "1cm = 5m"; //lblCSNo.Text = CStxt_ID; // ((LayerOverlay)Map1.CustomOverlays[1]).Redraw(); // Map1.CurrentExtent = Features[0].GetBoundingBox(); //lblDate.Text = DateTime.Now.ToLongDateString(); //Map1.CurrentExtent = ExtentHelper.GetDrawingExtent(Features[0].GetBoundingBox(), (float)Map1.WidthInPixels, (float)Map1.HeightInPixels); // if (!string.IsNullOrEmpty(RoadFile)) // { //ShapeFileFeatureLayer StreetsShapeLayer = new ShapeFileFeatureLayer("C:/MumbaiDivision/" + tahasil + "/" + RoadFile); //StreetsShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1; //StreetsShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //StreetsShapeLayer.DrawingMarginPercentage = 10; //StreetsShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.XOffsetInPixel = 30; //Map1.StaticOverlay.Layers.Add(StreetsShapeLayer); //Map1.StaticOverlay.TileType = TileType.MultipleTile; //ShapeFileFeatureLayer StreetsLabelLayer = new ShapeFileFeatureLayer(Get.RootFilePath + path.Tables[0].Rows[2]["Path"].ToString()); "C:/MumbaiDivision/" + tahasil + "/" + RoadFile // ShapeFileFeatureLayer StreetsLabelLayer = new ShapeFileFeatureLayer("C:/PMRDA/" + tahasil + "/" + Village + "/" + CTSFile); // StreetsLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.LocalRoad1("TEXTSTRING"); // StreetsLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; // StreetsLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.XOffsetInPixel = 30; // ShapeFileFeatureSource.BuildIndexFile(StreetsLabelLayer.ShapePathFileName); //StreetsLabelLayer.RequireIndex = false; //StreetsLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add("TEXTSTRING"); //StreetsLabelLayer.DrawingFeatures += new EventHandler(streetLayer_DrawingFeatures); // Map1.DynamicOverlay.Layers.Add(StreetsLabelLayer); // } //GetAppMapDetails(); // BindAllFeaturesToGridView(worldLayer); // int rpzone = int.Parse(Session["RP_ZONE"].ToString()); // int rpzone = 4; //((LayerOverlay)Map1.CustomOverlays[1]).Redraw(); //Map1.CurrentExtent = Features[0].GetBoundingBox(); //#region create new shape file to export original shape of survey no //worldLayer.Open(); //Collection inputDbfColumns = ((ShapeFileFeatureSource)worldLayer.FeatureSource).GetDbfColumns(); ////Adds all the columns from both shapefiles for the resulting shapefile. //Collection totalColumns = new Collection(); //foreach (DbfColumn dbfColumn in inputDbfColumns) //{ // totalColumns.Add(dbfColumn); //} //string shapeFileNm = "SurveyNo" + CStxt_ID + ".shp"; ////Creates the new shapefile that is the result of the intersection of the input shapefile and the intersecting shapefile. //if (File.Exists(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\" + shapeFileNm)) //{ // File.Delete(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\" + shapeFileNm); // File.Delete(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\SurveyNo" + CStxt_ID + ".ids"); // File.Delete(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\SurveyNo" + CStxt_ID + ".idx"); // File.Delete(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\SurveyNo" + CStxt_ID + ".dbf"); // File.Delete(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\SurveyNo" + CStxt_ID + ".shx"); //} //ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polygon, @"C:\MumbaiDivision\Narhe\IntersectedOutPut\" + shapeFileNm, totalColumns); ////Creates the new ShapeFileFeatureSource for the intersected data. //ShapeFileFeatureSource intersectShapeFileFeatureSource = new ShapeFileFeatureSource(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\" + shapeFileNm, ShapeFileReadWriteMode.ReadWrite); //intersectShapeFileFeatureSource.Open(); //intersectShapeFileFeatureSource.BeginTransaction(); //// Add features. ////Loops thru the features of the intersecting shapefiles. //// Collection intersectingFeatures = IntersectingShapeFileFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); ////foreach (Feature intersectingFeature in Features) ////{ //// ////Gets the features of the input shapefile to be intersected. ////MultipolygonShape intersectingMultiPolygonShape = (MultipolygonShape)intersectingFeature.GetShape(); ////Collection intersectedFeatures = InputShapeFileFeatureLayer.QueryTools.GetFeaturesIntersecting(intersectingMultiPolygonShape, ReturningColumnsType.AllColumns); ////Loops thru the features of the input shapefile to be intersected. //foreach (Feature intersectedFeature in Features) //{ // //Gets the MultipolygonShape as the result of the intersection. // MultipolygonShape intersectedMultipolygonShape = (MultipolygonShape)intersectedFeature.GetShape(); // //MultipolygonShape overlapMultipolygonShape = intersectedFeature.GetIntersection(intersectedMultipolygonShape); // //Gets the column values from both the input and the intersecting shapefile. // //Dictionary Columns = new Dictionary(); // //foreach (DbfColumn dbfColumn in inputDbfColumns) // //{ // // Columns.Add(dbfColumn.ColumnName, intersectedFeature.ColumnValues[dbfColumn.ColumnName]); // //} // //foreach (DbfColumn dbfColumn in intersectingDbfColumns) // //{ // // Columns.Add(dbfColumn.ColumnName, intersectingFeature.ColumnValues[dbfColumn.ColumnName]); // //} // // Adds the new feature with the intersected MultipolygonShape and the columns from both the input and the intersecting shapefiles. // Feature newFeature = new Feature(intersectedMultipolygonShape); // intersectShapeFileFeatureSource.AddFeature(newFeature); //} //// } //intersectShapeFileFeatureSource.CommitTransaction(); //intersectShapeFileFeatureSource.Close(); //string zoneFilePathGREEN = "GREEN.shp"; //string zoneFilePathYellow = "Residential.shp"; ////Create shape file for itersected polygon //// getIntersectedLines(CStxt_ID, shapeFileNm, zoneFilePathYellow); //// getIntersectedLines(CStxt_ID, shapeFileNm, zoneFilePathGREEN); //#endregion } } } catch (Exception ex) { // ex = ErrorLog.LoggingError(ex, "Report_frmParcelIdentification", "GetMapDetails()"); Response.Redirect(""); } } //To Draw Selected Feature Only void worldLayer_DrawingFeatures(object sender, DrawingFeaturesEventArgs e) { Collection featuresToDrawn = new Collection(); string Disp_ID = string.Empty; string[] strIDs = CStxt_ID.Split(','); int no = strIDs.Length; if (no >= 1) { foreach (Feature feature in e.FeaturesToDraw) { if (!string.IsNullOrEmpty(feature.ColumnValues[ID])) { Disp_ID = feature.ColumnValues[ID]; for (int a = 0; a < strIDs.Length; a++) { if (Disp_ID == strIDs[a]) { featuresToDrawn.Add(feature); } } } } e.FeaturesToDraw.Clear(); foreach (Feature feature in featuresToDrawn) { e.FeaturesToDraw.Add(feature); } } } protected void GetTahasil() { try { //if (string.IsNullOrEmpty(Request.QueryString["AppID"])) // Request.QueryString["AppID"] = App_ID.ToString(); //if (Request.QueryString["AppID"] != null) //{ VillageVO objVVo = new VillageVO(); VillageDAL objVDAL = new VillageDAL(); // VillageBAL objVBAL = new VillageBAL(); // AuthorisationManager obj = new AuthorisationManager(); DataSet dsTahasil = objVDAL.GetFilePath(App_ID); Village = dsTahasil.Tables[0].Rows[0][0].ToString(); //AuthoriseID = int.Parse(Authoriseid.Tables[0].Rows[0][0].ToString()) tahasil = dsTahasil.Tables[0].Rows[0][1].ToString(); // tahasil = "Gujrat"; //MapDAL obj = new MapDAL(); //path = obj.GetFilePath(App_ID); //tahasil = path.Tables[0].Rows[0]["Tahasil"].ToString(); if (!string.IsNullOrEmpty(tahasil)) { if (Village == "Hinjewadi") { Village = "Hinjewadi"; CTSFile = "Hinjewadi.shp"; //STRFile = "Bhuleshwar_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; //Village = "Bhuleshwar_Road_With_Sheet_Nos.shp"; } else if (tahasil == "Bhuleshwar") { tahasil = "Bhuleshwar"; CTSFile = "Bhuleshwar_CTS_Boundary_With_Sheet_Nos.shp"; STRFile = "Bhuleshwar_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; RoadFile = "Bhuleshwar_Road_With_Sheet_Nos.shp"; } else if (tahasil == "Colaba") { tahasil = "Coloba"; CTSFile = "Colaba_CTS_Close_Boundary_With_Sheet_Nos.shp"; STRFile = "Colaba_Structure_With_Sheet_Nos_&_CTS_Boundary_Nos.shp"; RoadFile = "Colaba_Road_With_Sheet_Nos.shp"; } else if (tahasil == "Dharavi") { tahasil = "Dharavi"; CTSFile = "Dharavi_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "Dharavi_Structure_With_Sheet_Nos_&_CTS_Nos.shp"; RoadFile = "Princes Division Lamination_Road Text.shp"; } else if (tahasil == "Fort") { tahasil = "Fort"; CTSFile = "Fort_Division_CTS_Boundary_POLY_With_Sheet_Nos.shp"; STRFile = "Fort_Division_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; RoadFile = "Fort_Division_Road_With_Sheet_Nos.shp"; } else if (tahasil == "Girgaon") { tahasil = "Girgaon"; CTSFile = "Girgaon_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "Girgaon_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; RoadFile = "Girgaon_Road_With_Sheet_Nos.shp"; } else if (tahasil == "Mazgaon") { tahasil = "Mazagaon"; CTSFile = "Mazagaon_CTS_Boundary_Polygon_With_Sheet_Nos.shp"; STRFile = "Mazagaon_Structure_With_Sheet_Nos_&_CTS_Boundary.shp"; RoadFile = "Mazagaon_Road_With_Sheet_Nos.shp"; } else if (tahasil == "PrincessDock") { tahasil = "PrincessDock"; CTSFile = "Princes Division Lamination_CTS_Boundry.shp"; STRFile = "Princes Division Lamination_Structer.shp"; RoadFile = "Princes Division Lamination_Road Text.shp"; } else if (tahasil == "SaltPan") { tahasil = "SaltPan"; CTSFile = "Saltpan_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "Saltpan_Structure_With_Sheet_Nos_&_CTS_Nos.shp"; RoadFile = "Saltpan_Road_With_Sheet_Nos.shp"; } else if (tahasil == "Sion") { tahasil = "Sion"; CTSFile = "Sion_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "Sion_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; RoadFile = "Sion_Railway_With_Sheet_Nos.shp"; } else if (tahasil == "Tardeo") { tahasil = "Tardeo"; CTSFile = "Taraddev_CTS_Boundary_With_Sheet_No.shp"; STRFile = "Taraddev_Structer_With_CTS_No_&_Sheet_No.shp"; } else if (tahasil == "Worali") { tahasil = "Worali"; CTSFile = "Varali_Division_CTS_Boundary_POLY_With_Sheet_Nos.shp"; STRFile = "Varali_Division_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; RoadFile = "Varali_Division_Road_With_Sheet_Nos.shp"; } else if (tahasil == "Mandvi") { tahasil = "Mandvi"; CTSFile = "Mandvi_CTS_Boundary_Poly_With_Sheet_No.shp"; STRFile = "Mandvi_Structure_With_CTS_No_&_Sheet_No.shp"; RoadFile = "Mandvi_Road_With_Sheet_No.shp"; } else if (tahasil == "DadarNaigaum") { tahasil = "DadarNaigaum"; CTSFile = "Dadar_Naygaon_CTS_Boundary_With_Sheet_No.shp"; STRFile = "Dadar_Naygaon_Structure_With_CTS_No_&_Sheet_No.shp"; RoadFile = "Dadar_Naygaon_Road_With_Sheet_No.shp"; } else if (tahasil == "Byculla") { tahasil = "Byculla"; CTSFile = "Byculla_CTS_Boundary_With_Sheet_No.shp"; STRFile = "Byculla_Structure_With_Sheet_No_&_CTS_No.shp"; //RoadFile = "Dadar_Naygaon_Road_With_Sheet_No.shp"; } else if (tahasil == "LoarParel") { tahasil = "LowerParel"; CTSFile = "LowerParel_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "LowerParel_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "Mahim") { tahasil = "Mahim"; CTSFile = "Mahim_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "Mahim_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "Matunga") { tahasil = "Matunga"; CTSFile = "Matunga_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "Matunga_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "ParelShivdi") { tahasil = "ParelShivdi"; CTSFile = "ParelShivdi_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "ParelShivdi_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "MalabarHillCambala") { tahasil = "MalabarHillCambala"; CTSFile = "MalabarHillCambala_CTS_Boundary_Poly_With_Sheet_Nos.shp"; STRFile = "MalabarHillCambala_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "TPS2_Mahim") { tahasil = "TPS2_Mahim"; CTSFile = "TPSI_Division_CTS_Boundary_POLY_With_Sheet_Nos.shp"; STRFile = "TPSI_Division_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "TPS3_Mahim") { tahasil = "TPS3_Mahim"; CTSFile = "TPSI_Division_CTS_Boundary_POLY_With_Sheet_Nos.shp"; STRFile = "TPSI_Division_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "TPS4_Mahim") { tahasil = "TPS4_Mahim"; CTSFile = "TPSI_Division_CTS_Boundary_POLY_With_Sheet_Nos.shp"; STRFile = "TPSI_Division_Structure_With_CTS_Nos_&_Sheet_Nos.shp"; } else if (tahasil == "Gujrat") { tahasil = "Gujrat"; CTSFile = "Bhavpura_2.shp"; STRFile = "Bhavpura_2.shp"; } else if (tahasil == "Narhe") { tahasil = "Narhe"; CTSFile = "Sampl04.shp";//"sr.shp"; STRFile = "Sampl04.shp";//"sr.shp"; //RoadFile = "Road.shp"; } /////////////////////////////// } //} } catch (Exception ex) { // ex = ErrorLog.LoggingError(ex, "Report_frmParcelIdentification", "GetTahasil()"); Response.Redirect("~/Common/ErrorPage.aspx?ExceptionId=" + ex.Data["ExceptionId"].ToString()); } } //By Archana on 29/3/2014 protected void GetAppMapDetails() { //if (Request.QueryString["AppID"] != null) //{ DataSet ds = null; MapDAL obj = new MapDAL(); ds = obj.GetMapDetails(14); if (ds.Tables[0].Rows.Count > 0) { lblSheetNo.Text = ds.Tables[0].Rows[0]["SheetNo"].ToString(); lblCSNo.Text = ds.Tables[0].Rows[0]["strCS"].ToString(); lblCSNo.Text = lblCSNo.Text.Remove(lblCSNo.Text.LastIndexOf(',', lblCSNo.Text.Length - 1)); lblDivName.Text = ds.Tables[0].Rows[0]["Tahasil"].ToString(); lblAmt.Text = ds.Tables[0].Rows[0]["TotalAmount"].ToString(); //lblMapScale1.Text = drpScale.SelectedItem.Text; //ds.Tables[0].Rows[0]["Scale"].ToString().Replace(":", "="); //lblCode.Text = ds.Tables[0].Rows[0]["RandomCode"].ToString(); } //} } public void clipping(string CS_No) { // Set the full extent and the background color //mapEngine.CurrentExtent = ExtentHelper.GetDrawingExtent(new RectangleShape(-99.26, 16.29, -26.37, -61.48), Map.Width, Map.Height); //mapEngine.BackgroundFillBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); // Adds the static layers to the MapEngine //Adds the countries background layer. //LayerOverlay staticOverlay = new LayerOverlay(); //LayerOverlay dynamicOverlay = new LayerOverlay(); Map1.MapUnit = GeographyUnit.DecimalDegree; ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\MumbaiDivision\Narhe\sr.shp", ShapeFileReadWriteMode.ReadOnly); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.County1; worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; mapEngine.StaticLayers.Add("WorldLayer", worldLayer); //ShapeFileFeatureLayer myLayer = new ShapeFileFeatureLayer(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\SurveyNo7.shp",ShapeFileReadWriteMode.ReadOnly); //myLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle=AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightGoldenrodYellow); //mapEngine.StaticLayers.Add("MyLayer", myLayer); //Adds the InMemoryFeatureLayer with of the polygon of any surveyno used for clipping. InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer(); inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle (GeoColor.StandardColors.Transparent, GeoColor.StandardColors.Black, 1); inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //Extract features of required surveyNo worldLayer.Open(); Collection features = worldLayer.FeatureSource.GetFeaturesByColumnValue("NAME", CS_No); worldLayer.Close(); inMemoryFeatureLayer.InternalFeatures.Add(features[0]); mapEngine.DynamicLayers.Add(inMemoryFeatureLayer); LayerOverlay baseOverlay = new LayerOverlay("BaseOverlay"); baseOverlay.IsBaseOverlay = false; baseOverlay.Layers.Add(inMemoryFeatureLayer); Map1.CustomOverlays.Add(baseOverlay); string[] shpFile1 = new string[3]; shpFile1[0] = "GREEN.shp"; shpFile1[1] = "Residential.shp"; shpFile1[2] = "FOREST.shp"; ShapeFileFeatureLayer[] clipLayer = new ShapeFileFeatureLayer[4]; Collection cFeatures = new Collection(); string shpFileNm = ""; for (int i = 0; i < 2; i++) { // Adds the evergreen layer to be clipped.D:\Project_26\ZoneTOPOLOGY\Residential.shp evergreenLayer = new ShapeFileFeatureLayer(@"D:\Project_26\ZoneTOPOLOGY\" + shpFile1[i], ShapeFileReadWriteMode.ReadOnly); evergreenLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightGreen, GeoColor.StandardColors.DarkGreen); evergreenLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; mapEngine.StaticLayers.Add("EverGreenLayer", evergreenLayer); //ButtonCLipcode //if (File.Exists(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\surveyShape13.shp")) //{ // DeleteClipFiles(); //} //Gets the MultipolygonShape of Brazil used for clipping. worldLayer.Open(); Collection features1 = worldLayer.FeatureSource.GetFeaturesByColumnValue("NAME", "7"); worldLayer.Close(); MultipolygonShape multiPolygonShape = (MultipolygonShape)features1[0].GetShape(); // MultipolygonShape m = (MultipolygonShape)f[0].GetShape(); shpFileNm = "SurveyNo" + CS_No + "_" + i + ".shp"; //Calls the ClipShapeFile function to get the clipped layer. clipLayer[i] = ClipShapeFile(evergreenLayer, @"C:\MumbaiDivision\Narhe\IntersectedOutPut\" + shpFileNm, multiPolygonShape); //Adds the clipped shapefile to the mapEngine. mapEngine.StaticLayers.Remove("EverGreenLayer"); //Adds the new clipped layer of evergreeen. ShapeFileFeatureLayer.BuildIndexFile(@"C:\MumbaiDivision\Narhe\IntersectedOutPut\" + shpFileNm, BuildIndexMode.DoNotRebuild); clipLayer[i].ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightGreen, GeoColor.StandardColors.DarkGreen); if (i == 1) { clipLayer[i].ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightGoldenrodYellow, GeoColor.StandardColors.Yellow); //dynamicOverlay.Layers.Add(clipLayer[i]); } clipLayer[i].ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; } // drawAdjacentFeatures(inMemoryFeatureLayer, worldLayer); LayerOverlay clippingOverlay1 = new LayerOverlay(); LayerOverlay clippingOverlay2 = new LayerOverlay(); LayerOverlay clippingOverlay3 = new LayerOverlay(); for (int j = 0; j < 2; j++) { if (j == 0) { clippingOverlay1.IsBaseOverlay = true; clippingOverlay1.Layers.Add(clipLayer[j]); Map1.CustomOverlays.Add(clippingOverlay1); } if (j == 1) { clippingOverlay2.IsBaseOverlay = true; clippingOverlay2.Layers.Add(clipLayer[j]); Map1.CustomOverlays.Add(clippingOverlay2); } //if (j == 2) //{ // clippingOverlay3.IsBaseOverlay = true; // clippingOverlay3.Layers.Add(clipLayer[j]); // Map1.CustomOverlays.Add(clippingOverlay3); //} } Map1.CurrentExtent = features[0].GetBoundingBox(); // Map1.ZoomToScale(10); // GetMapScale(); // DrawImage(); } private ShapeFileFeatureLayer ClipShapeFile(ShapeFileFeatureLayer shapeFileFeatureLayer, string outputShapeFileFeatureLayerPath, AreaBaseShape ClippingShape) { //Gets the columns from the polygon based shapefile. shapeFileFeatureLayer.Open(); Collection dbfColumns = ((ShapeFileFeatureSource)shapeFileFeatureLayer.FeatureSource).GetDbfColumns(); ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polygon, outputShapeFileFeatureLayerPath, dbfColumns); ShapeFileFeatureSource clippedShapeFileFeatureSource = new ShapeFileFeatureSource(outputShapeFileFeatureLayerPath, ShapeFileReadWriteMode.ReadWrite); //Gets the features with Spatial Query that will be used for the clipping. Collection features = shapeFileFeatureLayer.QueryTools.GetFeaturesIntersecting(ClippingShape, ReturningColumnsType.AllColumns); shapeFileFeatureLayer.Close(); //Loops thru all the features from the Spatial Query. clippedShapeFileFeatureSource.Open(); clippedShapeFileFeatureSource.BeginTransaction(); foreach (Feature feature in features) { //Gets the MultipolygonShape and clip it using GetIntersection geometric function. MultipolygonShape currentMultiPolygonShape = (MultipolygonShape)(feature.GetShape()); MultipolygonShape overlapMultiPolygonShape = currentMultiPolygonShape.GetIntersection(ClippingShape); //Adds the feature to the clipped layer with the clipped Multipolygon with its ColumnValues. Dictionary Columns = feature.ColumnValues; Feature clippedFeature = new Feature(overlapMultiPolygonShape, Columns); clippedShapeFileFeatureSource.AddFeature(clippedFeature); } clippedShapeFileFeatureSource.CommitTransaction(); clippedShapeFileFeatureSource.Close(); //Returns the clipped ShapeFileFeatureLayer. ShapeFileFeatureLayer clippedShapeFileFeatureLayer = new ShapeFileFeatureLayer(outputShapeFileFeatureLayerPath); clippedShapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightGoldenrodYellow); return clippedShapeFileFeatureLayer; } public void setAreaColor(string CSNO, InMemoryFeatureLayer inMemoryLayer1) { if (CSNO == "1" || CSNO == "2" || CSNO == "3" || CSNO == "4" || CSNO == "5" || CSNO == "6" || CSNO == "28" || CSNO == "30" || CSNO == "31" || CSNO == "32" || CSNO == "33" || CSNO == "34" || CSNO == "35" || CSNO == "39" || CSNO == "40" || CSNO == "41" || CSNO == "42" || CSNO == "43" || CSNO == "47" || CSNO == "48" || CSNO == "49" || CSNO == "51" || CSNO == "52" || CSNO == "53" || CSNO == "54" || CSNO == "55" || CSNO == "56" || CSNO == "57" || CSNO == "7A") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.StandardColors.Black); //PanelLegend.Visible = true; //txtLegend.BackColor = System.Drawing.Color.Yellow; //lblLegend.Text = "Residential"; inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.CharacterSolidBrush.Color = GeoColor.StandardColors.Black; } if (CSNO == "7B" || CSNO == "8" || CSNO == "9" || CSNO == "10" || CSNO == "11" || CSNO == "12" || CSNO == "13" || CSNO == "14" || CSNO == "15" || CSNO == "19" || CSNO == "20" || CSNO == "21" || CSNO == "22" || CSNO == "23" || CSNO == "24" || CSNO == "29" || CSNO == "45") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Green; //PanelLegend.Visible = true; //txtLegend.BackColor = System.Drawing.Color.Green; //lblLegend.Text = "Agriculture"; } if (CSNO == "25" || CSNO == "26" || CSNO == "27" || CSNO == "36" || CSNO == "37" || CSNO == "38" || CSNO == "44" || CSNO == "46" || CSNO == "50") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.Indigo; //PanelLegend.Visible = true; //txtLegend.BackColor = System.Drawing.Color.Indigo; //lblLegend.Text = "Military"; } if (CSNO == "16" || CSNO == "17" || CSNO == "18") { inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.StandardColors.DarkGreen; //PanelLegend.Visible = true; //txtLegend.BackColor = System.Drawing.Color.DarkGreen; //lblLegend.Text = "Forest"; } } protected void btnGenerateZonDakhla_Click(object sender, EventArgs e) { Panel1.Visible = true; //Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));//(GeoColor.StandardColors.SlateGray); Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White); Map1.CurrentExtent = new RectangleShape(-125, 72, 50, -46); //For GeographyUnit.DecimalDegree Unit Map1.MapUnit = GeographyUnit.Meter; //Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962); //Map1.CurrentExtent = new RectangleShape(-19268509.29874, 13535292.38285, 20656089.34576, -14435365.7673); // Map1.CurrentExtent = new RectangleShape(-5E-06, 5E-06, 5E-06, -5E-06); //Default RectangleShape //Image1.Visible = false; //To restrict ZoonIn,ZoomOut disable Pan Map1.MapTools.MouseMapTool.IsMouseWheelDisabled = true; Map1.MapTools.PanZoomBar.Enabled = false; //To disable double click Map1.MapTools.MouseMapTool.Enabled = false; //Image1.Visible = false; //createMapStructure(); //if (Request.QueryString["ParcelID"] != null) //{ //Session["Surveyno"] = SurveyNo; //Session["appid"] = App_ID; //Session["Tahsil"] = Tahasil; //Session["Village"] = Village; App_ID = int.Parse(Session["appid"].ToString()); Village = Session["Village"].ToString(); Tahasil = Session["Tahsil"].ToString(); SurveyNo = Session["SurveyNo"].ToString(); // CStxt_ID = SurveyNo;//Request.QueryString["ParcelID"]; // App_ID = int.Parse(txtApplicationID.Text); CStxt_ID = SurveyNo; // } //btnSet.Attributes.Add("OnClick", "IsValid('frmParcelIdentification')"); // lblError.Text = ""; // string[] strIDs = CStxt_ID.Split(','); // for (int a = 0; a < strIDs.Length; a++) //{ if (CStxt_ID != "0") { GetMapDetails(CStxt_ID); string NrthPath = HttpContext.Current.Server.MapPath("~/IMG/NorthImage/north4.png"); //NorthImage//NorthArrow.png System.Drawing.Image myImg = System.Drawing.Image.FromFile(NrthPath); string scale = "1cm : 5m"; //string Paper_Size = "A4"; Bitmap shape = Map1.GetBitmap((int)Map1.Width.Value, (int)Map1.Height.Value); ImageConverter ic = new ImageConverter(); byte[] imgArr1 = (byte[])ic.ConvertTo(shape, typeof(byte[])); byte[] imgArrNrth = (byte[])ic.ConvertTo(myImg, typeof(byte[])); MapDetailsDAL objMSDAL = new MapDetailsDAL(); int Rpzone = int.Parse(Session["rpzone"].ToString()); // DataAccessMapImage obj = new DataAccessMapImage(); objMSDAL.InsertImageMap(0, SurveyNo, imgArr1, imgArrNrth, App_ID, CStxt_ID, scale, Rpzone); Session["SurveyNp"] = CStxt_ID; Session["App_ID"] = App_ID; // Session["CS_ID"] = CStxt_ID; Session["Scale"] = scale; Response.Redirect("ReportPartPlan.aspx"); //GetMapStructure(); } else { //DisplayErrorMessage("0 is not a valid Cadastral Survey No."); } // } // Response.Redirect("ReportPartPlan.aspx"); //Session["menuVisit"] = "0"; //if (Request.QueryString["AppID"] != null) // App_ID = int.Parse(Request.QueryString["AppID"]); //drpScale.SelectedValue = "1cm : 5m"; //drpSize.SelectedValue = "A4"; //lblMapScale1.Text = "1cm : 5m"; //tbl1.Visible = false; //tbl2.Visible = false; //trNt.Visible = false; //trNtlbl.Visible = false; //trbott.Visible = false; //ApplicationManager obj = new ApplicationManager(); //DataSet dsRandomCode = new DataSet(); //dsRandomCode = obj.GetRandomCode("A",App_ID,0); //lblRandomCode.Text = dsRandomCode.Tables[0].Rows[0][3].ToString(); } private void BindAllFeaturesToGridView(FeatureLayer featureLayer) { MapDetailsDAL objMSDAL = new MapDetailsDAL(); MapDetailsVO objMSVO = new MapDetailsVO(); string[] returningColumns = new string[] { "OBJECTID_1", "OBJECTID", "PIN", "PIN1", "PIN2", "PIN3", "PIN4", "OTHERS", "VIL_CD", "TQ", "CEN_CD", "NAME_E", "RP_ZONE", "remark", "AREA", "PERIMETER", "PUNE_MA", "PUNE_MA_ID" }; featureLayer.Open(); Collection allFeaturs = featureLayer.FeatureSource.GetAllFeatures(returningColumns); featureLayer.Close(); DataTable dt = GetDataTableFromFeatures(allFeaturs, returningColumns); foreach (DataRow dr in dt.Rows) { if (dr["PIN"].ToString() == "SurveyNo") { // objMSVO.ShpFL_ID = 1; objMSVO.City_ID = 20342; objMSVO.Tahasil_ID = 3; objMSVO.Village_ID = 3; // objMSVO.ApplicationID = 91; objMSVO.OBJECTID_1 = dr["OBJECTID_1"].ToString(); objMSVO.OBJECTID = dr["OBJECTID"].ToString(); objMSVO.PIN = dr["PIN"].ToString(); objMSVO.PIN1 = dr["PIN1"].ToString(); objMSVO.PIN2 = dr["PIN2"].ToString(); objMSVO.PIN3 = dr["PIN3"].ToString(); objMSVO.PIN4 = dr["PIN4"].ToString(); objMSVO.OTHERS = dr["OTHERS"].ToString(); objMSVO.VIL_CD = dr["VIL_CD"].ToString(); objMSVO.TQ = dr["TQ"].ToString(); objMSVO.CEN_CD = dr["CEN_CD"].ToString(); objMSVO.NAME_E = dr["NAME_E"].ToString(); objMSVO.RP_ZONE = dr["RP_ZONE"].ToString(); objMSVO.remark = dr["remark"].ToString(); objMSVO.AREA = dr["AREA"].ToString(); objMSVO.PERIMETER = dr["PERIMETER"].ToString(); objMSVO.PUNE_MA = dr["PUNE_MA"].ToString(); objMSVO.PUNE_MA_ID = dr["PUNE_MA_ID"].ToString(); Session["RP_ZONE"] = dr["RP_ZONE"].ToString(); } } long j = objMSDAL.Save(objMSVO); //string Pin = string.Empty; //string rpzone = string.Empty; //foreach (DataRow dr in dt.Rows) //{ // // Here you get access to values at cell level. // // Place your desired logic here. // //Pin = dr["PIN"].ToString(); // if (dr["PIN"].ToString()=="250") // { // rpzone = dr["RP_ZONE"].ToString(); // } // // In case column names are not defined then // // Assuming you need 3rd column value then // // PIN = dr[2].ToString(); //} // shpData.DataSource = dt; // shpData.DataBind(); //FeaturesGridView.DataSource = //FeaturesGridView.DataBind(); } private static DataTable GetDataTableFromFeatures(Collection features, string[] columns) { DataTable dataTable = new DataTable(); if (features != null) { dataTable.Columns.Add("OBJECTID_1"); dataTable.Columns.Add("OBJECTID"); dataTable.Columns.Add("PIN"); dataTable.Columns.Add("PIN1"); dataTable.Columns.Add("PIN2"); dataTable.Columns.Add("PIN3"); dataTable.Columns.Add("PIN4"); dataTable.Columns.Add("OTHERS"); dataTable.Columns.Add("VIL_CD"); dataTable.Columns.Add("TQ"); dataTable.Columns.Add("CEN_CD"); dataTable.Columns.Add("NAME_E"); dataTable.Columns.Add("RP_ZONE"); dataTable.Columns.Add("remark"); dataTable.Columns.Add("AREA"); dataTable.Columns.Add("PERIMETER"); dataTable.Columns.Add("PUNE_MA"); dataTable.Columns.Add("PUNE_MA_ID"); //dataTable.Columns.Add("Currency"); // dataTable.Columns.Add("CountryId"); foreach (Feature feature in features) { AddRow(columns, feature, dataTable); } } return dataTable; } private static void AddRow(string[] returningColumns, Feature feature, DataTable dataTable) { DataRow dataRow = dataTable.NewRow(); for (int i = 0; i < returningColumns.Length; i++) { dataRow[i] = feature.ColumnValues[returningColumns[i]]; } dataTable.Rows.Add(dataRow); } } }