Query of GIS Secondary Development

Source: Internet
Author: User

Recently I have been working on the B/S project. Although I feel that it is not difficult, the complicated process and huge workload are helpless. There was no time to study GIS at work, so I had to go back to work and study it. As mentioned above, this section will introduce the right-click menu of maptoccontrol. Haha, This is not sorted out yet. Let's look at the GIS Query first. Haha.

Old Rules: You can see the truth in a picture.

In GIS, queries are classified into attribute queries and spatial queries. The corresponding interfaces are iqueryfilter and ispatialfilter. Of course, the latter inherits the former.

In, click ballooncallout with the mouse to bring up the ballooncallout, which is implemented by space query. In the query condition on the right, click the query button to locate the query as a property query. (Haha, I want you to know it at first glance .)

①: Property query code:

Code

# Query region attributes
Private void btnsearchcity_click (Object sender, eventargs E)
{
Iactiveview pactiveview = axmapmain. Map as iactiveview;
Igraphicscontainer pgrahpicscontainer = pactiveview as igraphicscontainer;
// Clear first
Pgrahpicscontainer. deleteallelements ();
Axmapmain. extent = pactiveview. fullextent;
Axmapmain. activeview. screendisplay. updatewindow ();

Ifeaturelayer pfeaturelayer = axmapmain. get_layer (1) as ifeaturelayer;
If (null = pfeaturelayer) MessageBox. Show ("select a layer not a feature layer ");
Iqueryfilter queryfilter = new queryfilterclass ();
Queryfilter. whereclause = "name = '" + this. cbcity. Text + "'";
Ifeaturecursor featurecursor = pfeaturelayer. Search (queryfilter, false );
Ifeature pfeature = NULL;
While (pfeature = featurecursor. nextfeature ())! = NULL)
{
Axmapmain. flashshape (pfeature. Shape );
}
}
# Endregion

 

②: Space Query

Code

# Region geometric Query
Private void axmapmain_onmousedown (Object sender, imapcontrolevents2_onmousedownevent E)
{
Ifeaturelayer pfeaturelayer = axmapmain. get_layer (1) as ifeaturelayer;
If (null = pfeaturelayer) return;

Ipoint point = new pointclass ();
Point. x = E. MapX;
Point. Y = E. mapy;

Ispatialfilter spatialfilter = new spatialfilterclass ();
Spatialfilter. Geometry = point;
Spatialfilter. spatialrel = esrispatialrelenum. esrispatialrelintersects;

Ifeaturecursor featurecursor = pfeaturelayer. Search (spatialfilter, true );
Ifeature pfeature = featurecursor. nextfeature ();

While (pfeature! = NULL)
{
Int Index = pfeature. Table. findfield ("name ");
String name = pfeature. Table. getrow (pfeature. OID). get_value (INDEX). tostring ();
Addballooncallout (E. MapX, E. mapy, name );
Axmapmain. flashshape (pfeature. Shape );
Pfeature = featurecursor. nextfeature ();
}

System. Threading. thread. Sleep (1000 );
Iactiveview pactiveview = axmapmain. Map as iactiveview;
Igraphicscontainer pgrahpicscontainer = pactiveview as igraphicscontainer;
Pgrahpicscontainer. deleteallelements ();
Axmapmain. activeview. screendisplay. updatewindow ();
Pactiveview. partialrefresh (esriviewdrawphase. esriviewgraphics, null, null );
}
# Endregion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.