geoserver cross-layer cql filter with feature id - geoserver

I want to get the features of layer A that have intersection with a specific feature in layer B (using the id of the feature in layer B). below is my query:
localhost:8080/geoserver/wms?LAYERS=sf:roads,sf:restricted,sf:bugsites&STYLES=&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:26713&CQL_FILTER=INCLUDE;INCLUDE;INTERSECTS(the_geom, querySingle('sf:restricted', 'the_geom','IN('restricted.4')'))&BBOX=589081.6705629,4914128.1213261,609174.02430924,4928177.0717971&WIDTH=512&HEIGHT=358
but the query cannot be parsed and I receive this error:

finally I fixed it...
I used two single quotations around the id and it works fine :| (one double quotation doesn't work).
INTERSECTS(the_geom, querySingle('sf:restricted', 'the_geom','IN(''restricted.4'')'))

The issue is in the query that gets the feature from the second layer (querySingle('sf:restricted', 'the_geom','IN('restricted.4')'))
The 3rd argument should be the where clause, including the field name and the desired value. As you are looking for a single ID, it could be 'ID=4'
Have a look at the example page, the ID field for sf:restricted is cat
querySingle('sf:restricted', 'the_geom','cat = 4')

Related

How pull in fields value from created parameter

I created a parameter [GroupID] that is used to query several datasets in my SSRS report. It is using the field [GroupID] from my GroupList_Rolling12 dataset. An example of [GroupID] is 77610N. When 77610N is selected, all of my datasets are correctly 'filtering' for this [GroupID].
I now need to create a text box that returns the [GroupName] of [GroupID]. In other words, when 77610N is selected from my GroupID parameter, I want the [GroupName] that is associated with the selected GroupID parameter to display.
I'm still very new to SSRS and cannot figure this out. I tried creating the expression =First(Fields!GroupName.Value, "GroupList_Rolling12") but that did not work since it simply returns the first value from the query.
I also tried =First(Parameters!GroupID.Value(0)) but this also did not work
I also tried this expression =Lookup(Fields!GroupID.Value, Fields!GroupID.Value, Fields!GroupName.Value, "GroupList_Rolling12")
)
Can you please help?
You can reference the parameter label directly like this
=Parameters!GroupID.Label
There is no need to put the index on the end (=Parameters!GroupID.Label(0)) unless your parameter is multi-value, in which case it would select the first selected entry.

How do I pass a list of values in string form to viewparams in geoserver?

I have a SQL view which takes two parameters. One of these parameters is a list of numbers in string form.
I can't for the life of me figure out if Geoserver can take this list and parse it.
The basic SQL query i've set up works as below
SELECT * FROM table WHERE id IN '%list%' AND layer = '%layer_name%'
When I put the default value for %list% as "1, 2 ,3" as an example, the call to viewparams might look like this
viewparams=layer_name:'layer_y';ids:1,2,3
Which fails. I've figured out that viewparams uses semicolons to distinguish between parameter types,
and commas as a way to distinguish between viewparams for different layers.
So I need a way of encapsulating my list of id values so that geoserver can parse them correctly.
Does anyone know how to do this?

Toad for Oracle bind variables with IN clause

I have a query that looks like this:
select * from foo where id in (:ids)
where the id column is a number.
When running this in TOAD version 11.0.0.116, I want to supply a list of ids so that the resulting query is:
select * from foo where id in (1,2,3)
The simple minded approach below gives an error that 1,2,3 is not a valid floating point value. Is there a type/value combination that will let me run the desired query?
CLARIFICATION: the query as shown is how it appears in my code, and I am pasting it into TOAD for testing the results of the query with various values. To date I have simply done a text replacement of the bind variable in TOAD with the comma separated list, and this works fine but is a bit annoying for trying different lists of values. Additionally, I have several queries of this form that I test in this way, so I was looking for a less pedestrian way to enter a list of values in TOAD without modifying the query. If this is not possible, I will continue with the pedestrian approach.
As indicated by OldProgrammer, the Gerrat's answer that "You can't use comma-separated values in one bind variable" in the indicated thread correctly answers this question as well.

Filtering Quotes by InventTable

I'm trying to build a report in AX 2009 (SP1, currently rollup 6) with a primary data source of the SalesQuotationLine table. Due to how our inventory is structured, I need to apply a filter that shows only certain categories of items (in this case, non-service items as defined in the InventTable). However, it seems that there is a problem in the link between the SalesQuotationLine and InventTable such that only two specific items will ever display.
We have tested this against the Sales Quotation Details screen as well, with the same results. Executing a query such as this:
...will only show quotes that have one of the specific items mentioned earlier. If we change the Item Type to something else (for example to Item), the result is an empty set. We are also getting this issue on one of our secondary test servers, which for all intents is a fresh install.
There doesn't seem to be any issues with the data mapping from the one table to the other, and we are not experiencing this issue with any other table set. Is this a real issue, or am I just missing something?
After analyzing the results from a SQL Profile run during the execution of the query, it seems the issue was a system bug. When selecting a table to join to the SalesQuotationLines, you have two options: 'Items' and 'Items (Item Number)'. Regardless of which table you select the query executes with, it joins the InventTable with the relation "SalesQuotationLines.ProjTransCode = InventTable.ItemId".
After comparing the table to other layers in the system, I found the following block of code removed from the createLine method (in the SYP layer):
if (this.ProjTransType == QuotationProjTransType::Item)
{
this.ProjTransCode = this.ItemId;
}
Since the ProjTransCode is no longer being populated, the join does not work except on certain quote lines that do have the ProjTransCode populated.
In addition, there is no directly defined relation to the InventTable - the link is only maintained via an Extended Data Type that is used on the SalesQuotationLine.ItemId field. Adding this relation in manually solved the problem.

Using Yahoo APIs, how to get list of locations matching certain prefix that have weather data available

I have an app that (among other things) uses Yahoo Weather API to display weather conditions for a location selected by user.
In the configuration dialog where user can enter the location, I'd love to offer autocompletion so that while user is typing location name, list of matching cities is suggested.
I can use YQL to fetch locations matching the prefix, i.e.:
select * from geo.places where text = 'Vie*'
but the problem is that not every location has a weather station associated with it and I'd love to skip these in my autocompletion list.
Using community tables (table called weather.woeid), following query will join previous query with the weather api, returning only locations that do have weather stations:
select location from weather.woeid where w in (select woeid from geo.places where text = 'Vie*')
This almost solves my problem, except for the fact that previous query (which produces same result as weather api call) doesn't return WOEID nor any kind of identifier I can use to directly query the Weather API after configuration. How can I capture the value of join parameter w? I tried something like select w, location ... but that doesn't seem to work.
Is there any other way to get list of locations (incl. WOEID) matching certain prefix that have weather data associated with them?
Afaik it is not possible with YQL to pass through values from the Sub-Select (the inner SELECT statement) to the outer SELECT, which I is what you want to do if I understand you correctly.
Based on your use case I want to propose another solution though:
I assume that the list of locations that have a weather station associated with them is relatively static, meaning this list does not change very often. If that is the case then it would not be very optimal in terms of performance to regenerate that list every time with YQL. Instead I would generate that list offline, store it in a file or MySQL or elsewhere and then just use that static list to answer to the AJAX call of your autocomplete field.
The data in that static list could look something like this:
{
"Vienna" => 72342,
"Hamburg" => 12334,
...
}
Once the user has selected a location and pressed enter, then you can send the YQL query to weather.woeid to look up the current weather based on the WOEID.

Resources