I have a WMS layer getting served from Geoserver. The layer exposes a date property that is stored in the database as a Date type. I would like to filter the layer by date range. For example: cql_filter=date>2015-07-01T00:00:00.000Z.
I am having a difficult time getting this to work and an unable to find any working examples.
Does any one have a working CQL date range example? Or Filter date range examples?
Thanks,
Nathan
My question asked for some working examples and Jason's answer provided just that.
Below are some working examples that filter a WMS by Date with leaflet.
A CQL example
var layer = L.tileLayer.wms('http://myWMSUrl', {
layers: 'namespace:layer',
format: 'image/png',
transparent: true,
version: '1.1.1',
cql_filter: 'date AFTER 2015-07-01T00:00:00Z AND date BEFORE 2015-07-01T00:00:00Z'
});
A Filter XML example
var layer = L.tileLayer.wms('http://myWMSUrl', {
layers: 'namespace:layer',
format: 'image/png',
transparent: true,
version: '1.1.1',
filter: '<PropertyIsGreaterThan><PropertyName>date</PropertyName><Function name="dateParse"><Literal>yyyy-MM-dd</Literal><Literal>2015-07-01</Literal><Function></PropertyIsGreaterThan>'
});
This link has some examples.
Intro to CQL
One thing that I have run into with CQL is the case sensitivity and field naming. In your example you reference date as a field. Maybe date is a reserved word? Try bumping up your logging in geoserver and check for errors or see what SQL gets generated. Double check the field name in the layer definition.
Related
What is the best way to store a date in UK format (d-m-Y) rather than the default (Y-m-d) default in the backend of OctoberCMS?
Change the format in the YAML file. Plugins/Author/Plugin/Models/PluginModel/fields.yaml . Look at the documentation here.
published_at:
label: Published
type: datepicker
mode: date
format: d-m-Y
If you are using the Builder plugin there is a spot for "format".
I've been having problems rendering the dates even after formatting the dates.. I'm using openweather api for 3 hours forecast and trying to render the date as dt_txt format. Can I just use dt_txt for date instead of dt converting to simple date?
Without knowing how you retrieve the other data from the list it is hard to point you in the right direction. But I'll give it a try.
According to the docs cnt means that the list has 40 objects in your case.
You're only using the first one [0] over here:
date: DateTime.fromMillisecondsSinceEpoch(
json['list'][0]['dt'] * 1000,
isUtc: false)
If you want to use dt_text from each object you need to do something this using an index.
json['list'][index]['dt_txt']
A simple example using a for loop could also be:
List<String> dateList = [];
for(var data in json['list']){
dateList.add(data['dt_txt']);
}
I have a fusiontable based feature collection in Google-Earth-Engine that includes a date column. I would like to cast the FC into an empty image and display with graduated colours for increasing dates - so that when the Inspector is used a human readable date is displayed.
var empty64 = ee.Image().toInt64();
var outlines = empty64.paint({
featureCollection: SomeFeatureCollection,
color: 'StartDate',
});
If I add this to the map as a layer I get the date as a 13-digit format that I can't read. How can I change this?
Thank you!
Per the API reference for Image.paint, color must be an object name or a number. To me, that means the EE API will interpret the object as a number, meaning a Date object will be converted from a string to a numerical representation. In this case, that's the "milliseconds since epoch" format.
Without a way to add metadata to a FeatureCollection (i.e. so you could store the associated datestring along with the other parameters of the feature), I don't think you can show a human readable date in the inspector.
I am busy learning Yii2, looking at this guide:
Yii documentation
In my customer table I have a field: customer_birthday which is of type: Date
Trying this code:
public function getBirthdayText()
{
return date('d/m/Y', $this->customer_birthday);
}
Running my page, getting this error:
A non well formed numeric value encountered on the line:
return date('d/m/Y', $this->customer_birthday);
Why do I get this error?
Yii 2 comes with very useful Formatter, which you can use to format your date.
Link: http://www.yiiframework.com/doc-2.0/yii-i18n-formatter.html#asDate()-detail
You should first properly configure formatter: http://www.yiiframework.com/doc-2.0/guide-output-formatting.html#configuring-formatter
And then format your dates in your needs: http://www.yiiframework.com/doc-2.0/guide-output-formatting.html#date-and-time
I have Date data and converted to string "2014-04-16 08:27:52" from my local PostgreSQL.
Please explain me how to set it at Parse.com as Date datatype?
In the docs on rest API search on date and see the json type and format :
"__type":"Date","iso":"2011-08-21T18:02:52
That would be Included in the date elements json used in the post.
I just figured it out:
var date = new Date("2014-04-16 08:27:52");
object.set("last_update",date);
In PHP, you can do:
$parse->someDate = $parse->dataType( 'date', '1985-01-01' );
In JavaScript, you can do:
var someDate = new Date("1985-01-01");
yourclass.set( 'someDate', { "__type": "Date", "iso": someDate.toISOString() } );
For Parse.com and PHP, the answer is less straight forward than what is presented here. It took me a while to figure out that dataType() isn't working for some reason in the SDK.
It seems many people got the $parse->dataType() syntax from here. But I can't find this function anymore in the official SDK.
Then there is this bug and the resulting function from StackOverflow, but neither of these are very user friendly.
As it turns out, the Parse PHP SDK will handle an array for the value in the createdAt, updatedAt, and other special data types.
This code works (essentially a direct port from their REST API / JavaScript):
$query->greaterThanOrEqualTo("createdAt", ["__type" => "Date", "iso" => date('Y-m-01\TH:i:s')]);
Feel free to use that format for other special types, like GeoPoints.