ThinkGeo.com    |     Blog    |     Wiki    |     Support

Regarding shape file

Hi,
I want to show some portion of shape file depending on condition(village).I have used stop certain features from drawing form web edition sample.It partially succeeded.But its only showing boundary of selected village and not the gut no.s.
My output should be like this Image1
Image1
But I’m getting as Image2

Regards,
Mouni_M

Hi Mouni,

It looks your render logic hadn’t set correct text style, or the gray area layer hadn’t been added into map, please check that.

You should want to reference our samples here:

Or you can choose upload your sample here, we will help you to make it works.

Regards,

Ethan

Hi Ethan,
This is my Method in which I’ve written an event and again mentioned TextStyle n Areastyle.But nothing get changed

protected void drpVillage_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
ShapeFileFeatureLayer shapeFileLayer = (ShapeFileFeatureLayer)((LayerOverlay)Map1.CustomOverlays[“StaticOverLay”]).Layers[“ShapeLayer”];
shapeFileLayer.DrawingFeatures += new EventHandler(shapeFileLayer_DrawingFeatures);
shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.StandardColors.Gray, 1);
shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“Gut_Number”, “Arial”, 7, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);

            InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)((LayerOverlay)Map1.CustomOverlays["DynamicOverlay"]).Layers["HighlightLayer"];
            
            highlightLayer.Open();
            highlightLayer.Columns.Add(new FeatureSourceColumn("GovtLand_G"));

            shapeFileLayer.Open();
            SQLstr = "Select Gut_Number from ALL where Village_Na='"+drpVillage.SelectedItem.Text+"'";
            dtSQL = shapeFileLayer.QueryTools.ExecuteQuery(SQLstr);
            shapeFileLayer.FeatureSource.Open();
            Collection<Feature> features1 = shapeFileLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
            highlightLayer.InternalFeatures.Clear();
            for (int i = 0; i < features1.Count; i++)
            {
                if (features1[i].ColumnValues["Village_Na"] == drpVillage.SelectedItem.Text && (features1[i].ColumnValues["GovtLand_G"] == "Forest" || features1[i].ColumnValues["GovtLand_G"] == "Government"))
                {
                    highlightLayer.InternalFeatures.Add(features1[i].Id, features1[i]);
                }
            }
            shapeFileLayer.Close();
            ValueStyle valueStyle = new ValueStyle();
            valueStyle.ColumnName = "GovtLand_G";
            valueStyle.ValueItems.Add(new ValueItem("Forest", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(130, 38, 153, 0)))));
            valueStyle.ValueItems.Add(new ValueItem("Government", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110, 245, 245, 122)))));
            highlightLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            if (highlightLayer.InternalFeatures.Count > 0)
            {
                highlightLayer.Open();
                Map1.CurrentExtent = highlightLayer.GetBoundingBox();
                highlightLayer.Close();
            }
            else
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", " alert('No Data Found...');", true);

            ((LayerOverlay)Map1.CustomOverlays["StaticOverLay"]).Redraw();
        }
        catch (Exception ex)
        {
            ex = Errorlog.LoggingError(ex, "LandAssetMapping", "drpVillage_SelectedIndexChanged()");
            Response.Redirect("~/Pages/Error.aspx?ExceptionId=" + ex.Data["ExceptionId"].ToString());
        }
    }

/****** This is an event ******************/
void shapeFileLayer_DrawingFeatures(object sender, DrawingFeaturesEventArgs e)
{
Collection featuresToDrawn = new Collection();
ShapeFileFeatureLayer shapeFileLayer = (ShapeFileFeatureLayer)((LayerOverlay)Map1.CustomOverlays[“StaticOverLay”]).Layers[“ShapeLayer”];

        shapeFileLayer.Open();
        Collection<Feature> AllFeatures = shapeFileLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);

        InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)((LayerOverlay)Map1.CustomOverlays["DynamicOverlay"]).Layers["HighlightLayer"];
        highlightLayer.InternalFeatures.Clear();

        for (int j = 0; j < AllFeatures.Count; j++)
        {
            if (AllFeatures[j].ColumnValues["Village_Na"].ToString() == drpVillage.SelectedItem.Text)
            {
                for (int i = 0; i < dtSQL.Rows.Count; i++)
                {
                    shapeFileLayer.FeatureSource.Open();
                    //int vGut = GetNumberOnly(dtSQL.Rows[i]["Gut_Number"].ToString());
                    //Feature vfeature = shapeFileLayer.QueryTools.GetFeatureById(vGut.ToString(), ReturningColumnsType.AllColumns);
                    Collection<Feature> vfeature = shapeFileLayer.QueryTools.GetFeaturesByColumnValue("Gut_Number", dtSQL.Rows[i]["Gut_Number"].ToString());
                    if (vfeature != null)
                    {
                        featuresToDrawn.Add(vfeature[0]);
                    }
                }
            }
        }
        //}
        e.FeaturesToDraw.Clear();
        foreach (Feature feature in featuresToDrawn)
        {
            e.FeaturesToDraw.Add(feature);
        }
    }

Hi Mouni,

It looks you forget apply the style to every levels:
shapeFileLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

I think that’s why your layer don’t shows.

Regards,

Ethan

Hi Ethan,
Thank you for replying.I applied style too though its not showing.

Regards,
Mouni_M

Hi Mouni,

Thanks for your feedback, could you please build a sample with your data and your code, so we can look into it and help you solve this problem?

You can modify based on our sample for example: https://github.com/ThinkGeo/HelloWorldSample-ForWebForms

Regards,

Ethan

Hi Ethan,
I am attaching here Sample web app. And Shape Files.Please copy shape files in App_Data folder.
SampleWebApp (2).zip (2.6 MB)
Shape1.zip (129.6 KB)
ShapeFiles.zip (3.7 MB)

Regards,
Mouni

Hi Mouni,

Thanks for your sample and data.

I think the problem is because the unit of your data ALL.shp and PURANDAR.shp is meter, but you think they are decimal degree and try to convert them into meter again.

Here is the result after comment some lines:

        //talukaLayer.FeatureSource.Projection = proj4;
        //villageLayer.FeatureSource.Projection = proj4;

image

I hope that’s solve your issue.

Regards,

Ethan

Hi Ethan,
thank you for your reply.
//talukaLayer.FeatureSource.Projection = proj4;
//villageLayer.FeatureSource.Projection = proj4;
Above two commented lines are WGS84 projection.Because of it shape files placed at its exact psiotion on google map.So i can not comment that two lines.
If I change Map unit to DecimalDegree my file does not display.
My final output is this:


But I want result like below image which is highlighted by black outline.
Image1

Regards,
Mouni

Hi Mouni,

In your first question you mentioned your result looks like this:
image

But now you mentioned the result is like this:

It looks the shape posistion and style is just the same like your target:
Image1

Just without the black line.

By run your sample I also hadn’t found where is the different.

In fact I am confused about it, if I misunderstand anything please let me know.

Regards,

Ethan

Hi Ethan,
thank you for your reply,
Actually,I just want this highlighted portion to be cut from shapefile and display that only with proper gut numbres in it.Like this image
https://community.thinkgeo.com/uploads/default/original/3X/1/f/1f072e6cc1320c8ae8e9cf1c8c1f8a7d8a381fc0.png
I partially succeeded to show this like below image.But that is not what i want.
https://community.thinkgeo.com/uploads/default/original/3X/f/1/f1b8dc6688a2b2b875c3de4f4f71a9c3b2333433.png
In this image gut numbers and village layer is not visible.
I dont know where i am getting wrong.
Regards,
Mouni_M

Hi Mouni,

Your code have some problems, I solved some of them, and it should works like this:

image

And here is the modified code:

WebForm1.aspx.cs.zip (2.9 KB)

I hope that’s helpful.

Any question please let me know.

Regards,

Ethan

Hi Ethan,
thank you for your reply.

Regards,
Mouni_M

Hi Mouni,

Any question please feel free to let us know.

Regards,

Ethan