基于C#的ArcEngine二次开发38: 几何关系描述接口- ISpatialFilter 最全解析(二)

简介: 基于C#的ArcEngine二次开发38: 几何关系描述接口- ISpatialFilter 最全解析

2.4 IQueryFilter.WhereClause Property


该属性允许指定一个表达式,其实就是一个sql语句,用来返回需要的要素;如你要获取面积大于1500的多边形,则应设置该参数为"AREA" > 1500;查询语法因使用的数据库而异,应用程序可以使用工作区上的ISQLSyntax接口来确定有关所用SQL语法的信息,例如限定表和字段名中使用的定界字符以及标识符引号字符。


The syntax of the query differs depending on the data source you are using, as it is in the native format of the database or data source.  An application can use the ISQLSyntax interface on a Workspace to determine information about the SQL syntax used, such as the delimiting character used in qualifying table and field names and the identifier quote character.


关于字段名:


如果查询数据是file geodatabase, shapefile, dBase table, coverage, INFO table,字段名应该使用双引号括起来,  "AREA"

如果查询的是个人数据库,应该使用中括号【square brackets】括起来 [AREA]

如果数据是 ArcSDE geodatabase、ArcIMS image service或feature service,不用括起来,  AREA

如果是.xls或.txt,字段使用单引号【single quotes】定义 'AREA' unless you are working in the Select By Attributes dialog launched from the table window, in which case square brackets [AREA] are used.

关于字符串:


字符串要使用单引号括起来:"STATE_NAME" = 'California'

使用转换函数处理数据库对字段值大小写敏感的情形:Personal geodatabases stored in Access are case insensitive to field values, whereas ArcSDE, File and shapefiles are case sensitive.  To make a case insensitive search in other data formats, you can use a SQL function to convert all values to the same case. For file-based data sources, use either the UPPER or LOWER function.

For example, given a field value of "Florida", a WhereClause of "State_name = 'florida'" will return one USA state when run against a data in a personal geodatabase, but none with and shapefiles and ArcSDE.  A WhereClause of "State_name = 'Florida'" will return one feature in all cases.

For example, the following expression will select customers whose last name is stored as either Jones or JONES: UPPER("LAST_NAME") = 'JONES'

Other data sources have similar functions. Personal geodatabases, for example, have functions named UCASE and LCASE that perform the same function.

使用LIKE运算符而非=运算符构架一个局部字符串搜索Use the LIKE operator (instead of the = operator) to build a partial string search.

For example, this expression would select Mississippi and Missouri among the USA state names:"STATE_NAME" LIKE 'Miss%'

如果对带=的字符串使用通配符,该字符将被视为字符串的一部分,而非通配符。If you use a wildcard character in a string with the = operator, the character is treated as part of the string, not as a wildcard.

通配符的使用:


代表一个或多个字符的记号

%表示该位置有任何位数的字符,可以是一个、100个或者没有;当你想搜索表示一个位置的通配符,_是备选方案。For any file-based data, '%' means that anything is acceptable in its place: one character, a hundred characters, or no character. Alternatively, if you want to search with a wildcard that represents one character, use '_'.

For example, this expression would select any name starting with the letters Cath, such as Cathy, Catherine, and Catherine Smith: "NAME" LIKE 'Cath%';使用%代替所有后边的字符

But this expression would find Catherine Smith and Katherine Smith:"OWNER_NAME" LIKE '_atherine smith';代替开头的一个字符

使用?表示任意数字字符,使用*表示单个字符:The wildcards you use to query personal geodatabases are '*' for any number of characters and '?' for one character.

Use ISQLSyntax::GetSpecialCharacter to return the wildcard specific for the data source being queried.【返回指定数据源特定的通配符】

对于链接表,使用与查询链接侧的通配符;查询仅面向目标侧,则使用目标侧通配符;查询仅面向链接表,则使用链接侧通配符;如果涉及两侧,则使用 % 和 \u 通配符。

For example, if you join a dbf file (the join table) to a personal geodatabase feature class (the target table):


1) Use * for queries that only involve personal geodatabase fields.


2) Use % for queries that only involve dbf columns.


3) Use % for queries involving columns from both sides of the table.


空值:Null values are supported in fields for geodatabases and for date fields in shapefiles/dBASE tables and coverages/INFO tables.

不等于:The Distinct keyword is not supported by file geodatabases.  The recommended workaround is to use the IDataStatistics::UniqueValues method to return the distinct values for a field.

比较数字:You can query numbers using the equal (=), not equal (<>), greater than (>), less than (<), greater than or equal (>=), and less than or equal (<=) operators.例如:"POPULATION96" >= 5000


查询日期:The syntax required for querying dates depends on the data type. ArcMap will automatically write the proper syntax for you when you double-click a date value in the Unique Values list. See the SQL reference mentioned above for more about querying dates.


关于SQL的参考网址:http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=SQL_reference


2.5 其他属性

[C#]public esriSearchOrderSearchOrder {get; set;}


请注意esriSearchOrderSpatial是默认属性,  以下esriSearchOrder枚举值用于设置搜索顺序:

esriSearchOrderAttribute:Sets the search order to attribute first.

esriSearchOrderSpatial:Sets the search order to spatial first.

[C#] public boolFilterOwnsGeometry {get;}
  • 过滤器是否属于查询图形
1. [C#] public IGeometryGeometry {get; set;}
2. [C#] public void set_GeometryEx ( IGeometryGeometry, boolA_2)

高级图形或图形包,如多边形、多段线、点、多点可以使用;低级图形,如路径、环、弧、曲线、线不能使用;

被IRelationalOperator接口实现的几何图形都支持,没有被其实现的都不支持。

The boolean parameter represents the FilterOwnsGeometry property.

Only high-level geometries, envelopes and geometry bags can be used. High-level geometries are polygons, polylines, points, and multipoints. Low-level geometries including paths, rings, arcs and curves, and lines can not be used. To test whether a geometry is applicable, see if it implements the IRelationalOperator interface; if it does, it can be used.

[C#] public stringGeometryField {get; set;}
  • 将用于滤波的几何图像字段名
[C#]public ISpatialReference get_OutputSpatialReference (stringFieldName);
[C#]public void set_OutputSpatialReference (stringFieldName, ISpatialReferenceOutputSpatialReference);
  • 为给定字段输出几何图形的空间参考。

3 空间关系描述优秀论文

2020050509444359.jpg

2020050509444386.jpg

20200505094443443.jpg

20200505094443796.jpg

20200505094444212.jpg


20200505094444646.jpg


20200505094445286.jpg

20200505094445286.jpg


相关文章
|
17天前
|
监控 前端开发 JavaScript
实战篇:商品API接口在跨平台销售中的有效运用与案例解析
随着电子商务的蓬勃发展,企业为了扩大市场覆盖面,经常需要在多个在线平台上展示和销售产品。然而,手工管理多个平台的库存、价格、商品描述等信息既耗时又容易出错。商品API接口在这一背景下显得尤为重要,它能够帮助企业在不同的销售平台之间实现商品信息的高效同步和管理。本文将通过具体的淘宝API接口使用案例,展示如何在跨平台销售中有效利用商品API接口,以及如何通过代码实现数据的统一管理。
|
1月前
|
IDE C# 开发工具
C#系列之接口介绍
C#系列之接口介绍
|
1月前
|
XML 前端开发 数据格式
请描述如何使用`BeautifulSoup`或其他类似的库来解析 HTML 或 XML 数据。
【2月更文挑战第22天】【2月更文挑战第67篇】请描述如何使用`BeautifulSoup`或其他类似的库来解析 HTML 或 XML 数据。
|
3月前
|
达摩院 Linux API
阿里达摩院MindOpt求解器V1.1新增C#接口
阿里达摩院MindOpt求解器发布最新版本V1.1,增加了C#相关API和文档。优化求解器产品是求解优化问题的专业计算软件,可广泛各个行业。阿里达摩院从2019年投入自研MindOpt优化求解器,截止目前经历27个版本的迭代,取得了多项国内和国际第一的成绩。就在上个月,2023年12月,在工信部产业发展促进中心等单位主办的首届能源电子产业创新大赛上,MindOpt获得电力用国产求解器第一名。本文将为C#开发者讲述如何下载安装MindOpt和C#案例源代码。
136 3
阿里达摩院MindOpt求解器V1.1新增C#接口
|
3月前
|
编译器 C# 开发者
C# 11.0中的新特性:覆盖默认接口方法
C# 11.0进一步增强了接口的灵活性,引入了覆盖默认接口方法的能力。这一新特性允许类在实现接口时,不仅可以提供接口中未实现的方法的具体实现,还可以覆盖接口中定义的默认方法实现。本文将详细介绍C# 11.0中接口默认方法覆盖的工作原理、使用场景及其对现有代码的影响,帮助开发者更好地理解和应用这一新功能。
|
3月前
|
安全 C# 开发者
C#中的默认接口方法:接口演化的新篇章
【1月更文挑战第11天】本文探讨了C# 8.0中引入的默认接口方法,这一特性允许在接口中定义具有默认实现的方法。文章介绍了默认接口方法的语法、使用场景,以及它们如何影响接口的设计和实现,同时讨论了默认接口方法带来的好处和潜在的陷阱。
|
15天前
|
存储 安全 Go
掌握Go语言:Go语言类型转换,无缝处理数据类型、接口和自定义类型的转换细节解析(29)
掌握Go语言:Go语言类型转换,无缝处理数据类型、接口和自定义类型的转换细节解析(29)
|
7天前
|
安全 Java 编译器
接口之美,内部之妙:深入解析Java的接口与内部类
接口之美,内部之妙:深入解析Java的接口与内部类
25 0
接口之美,内部之妙:深入解析Java的接口与内部类
|
23天前
|
监控 Linux 编译器
Linux C++ 定时器任务接口深度解析: 从理论到实践
Linux C++ 定时器任务接口深度解析: 从理论到实践
67 2
|
2月前
|
数据挖掘 API 数据处理
获取商品详情信息API接口:1688开放平台功能解析
首先,要获取商品详情信息,开发者需要向1688开放平台申请相应的权限,并遵循其调用规则。在调用商品详情信息API接口时,需要传入相应的请求参数,如商品ID、调用时间戳、密钥等。这些参数对于确保接口的正常运行至关重要。

推荐镜像

更多