Public Sub TimeQuery() Dim pMxDocument As IMxDocument Set pMxDocument = ThisDocument '[タイム スライダ] ウィンドウ Dim pMapTimeDisplay As IMapTimeDisplay Set pMapTimeDisplay = pMxDocument.FocusMap Dim pTimeReference As ITimeReference Set pTimeReference = pMapTimeDisplay.TimeReference '[時間表示] → [タイム ゾーン] Dim pFeatureLayer As IFeatureLayer Set pFeatureLayer = pMxDocument.FocusMap.Layer(0) 'Use time setting Dim pTimeData As ITimeData Set pTimeData = pFeatureLayer pTimeData.UseTime = True 'Timeの作成 Dim pStartTime As ITime Set pStartTime = New Time pStartTime.SetFromTimeString esriTimeStringFormat.esriTSFYearThruSecondWithSlash, "2000/09/01 12:00:00" 'Japanese date time style is "YYYY/MM/DD HH:MM:SS" Dim pEndTime As ITime Set pEndTime = New Time pEndTime.SetFromTimeString esriTimeStringFormat.esriTSFYearThruSecondWithSlash, "2000/09/30 12:00:00" 'TimeExtentの作成 Dim pTimeExtent As ITimeExtent Set pTimeExtent = New TimeExtent Set pTimeExtent.TimeReference = pTimeReference pTimeExtent.StartTime = pStartTime pTimeExtent.EndTime = pEndTime ' pTimeExtent.SetExtent pStartTime, pEndTime 'TimeQueryFilterの作成 Dim pTimeQueryFilter As ITimeQueryFilter Set pTimeQueryFilter = New TimeQueryFilter Set pTimeQueryFilter.OutputTimeReference = pTimeReference pTimeQueryFilter.TimeRelation = esriTimeRelation.esriTimeRelationOverlaps Set pTimeQueryFilter.TimeValue = pTimeExtent 'FeatureClassに対してはTimeQueryFilterが利用できないのでSQLで記載する ' Dim pQueryFilter As IQueryFilter ' Set pQueryFilter = New QueryFilter ' pQueryFilter.WhereClause = "Date_Time > date '2000/09/01 12:00:00' AND Date_Time < date '2000/09/30 12:00:00'" 'Search Dim pFeatureCursor As IFeatureCursor Set pFeatureCursor = pFeatureLayer.Search(pTimeQueryFilter, False) Dim pFeature As IFeature Set pFeature = pFeatureCursor.NextFeature Do Until pFeature Is Nothing 'Output Debug.Print pFeature.OID, pFeature.Value(10) Set pFeature = pFeatureCursor.NextFeature Loop End Sub
TimeQueryFilter の使用方法
2016/9/1 (木)