Overpass API query for specific store names - openstreetmap

I am trying to find Costco (or similar) stores in a given area. I have tried a few queries with no luck so far. Currently I'm using Turbo, but I believe I know how to switch to http and JSON. Any advice n a working query is greatly appreciated.
Attempts include:
(a)
node
[name=Costco]
({{bbox}});
out;
This runs, but no results where I know there should be.
(b)
node
[brand:wikipedia=en:Costco]
({{bbox}});
out;
I found the brand info in results for an OpenStreetmaps search, so I think the data is in the database.
This gives error
An error occurred during the execution of the overpass query! This is what overpass API returned:
Error: line 10: parse error: '!', '~', '=', '!=', or ']' expected - ':' found.
Error: line 10: parse error: ']' expected - ':' found.

You need to enclose brand:wikipedia and en:Costco in quotes. This should work:
node ["brand:wikipedia"="en:Costco"] ({{bbox}}); out;
Try the following query:
[out:json][timeout:25];
// gather results
(
// query part for: “shop=* and name=Costco”
nwr["shop"]["name"="Costco"]({{bbox}});
// query part for: “shop=* and brand=Costco”
nwr["shop"]["brand"="Costco"]({{bbox}});
// query part for: “shop=* and operator=Costco”
nwr["shop"]["operator"="Costco"]({{bbox}});
);
// print results
out body;
>;
out skel qt;
This searches for shops with the name, brand or operator "Costco".
You can see an example at overpass-turbo: https://overpass-turbo.eu/s/16OL

Related

Highway intersecting Waterbodies in OSM (Overpass query)

I am trying to run an Overpass Query for extracting all the highway features (highway=*) that might overlap the water features (natural=water). The highway features might be a dead end in the water feature or invalid overlap on water feature. I am a newbie so still trying to figure out the correct query. This is the query I have used so far:
[out:json][timeout:2500];
(
way["highway"]->.h;
way["natural"="water"]->.w1;
node.(w.h).(w.w1)({{bbox}});
);
out meta;
out skel qt;
However it shows the error:
"
An error occurred during the execution of the overpass query! This is what overpass API returned:
Error: line 10: parse error: ';' expected - 'w' found.
"

How to correct use $X in jasper??. Problem with parameters and IN clause in JSS

I have a report made with Jaspersoft Studio and in the dataset query I need to use an IN clause, for that I am using the expression "$X{IN ..."
Question # 1: What is the correct type to use for the parameter?
I'm using the following format:
Question # 2: How do I test in the preview?
Parameters screen:
To help, follow the excerpt of where with the parameter being used:
"...Where (($X{IN, db.empresa, paramIdEmpresa}) OR $ P!{ParamIdEmpresa} IS NULL) and (db_view ... "
Error that appears in the preview with the above parameters:
net.sf.jasperreports.engine.JRException: Error executing SQL statement
for: unit1. at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport
(ReportController.java:551) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access
(BaseFillHandle.java:135) at java.lang.Thread.run (Thread.java:748)
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at
or near "["   Position: 199 at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse
(QueryExecutorImpl.java:2440) at
org.postgresql.core.v3.QueryExecutorImpl.processResults
the problem was in the query and not in jasper...
the correct query is:
where
(($X{IN,db.idempresa, paramIdEmpresa}) OR db.idempresa IS NULL )
thanks to GP...
The best possible way to solve it is simple:
create a parameter called $P!{paramWhere}. of your application
pass the complete where clause with this parameter, e.g. "id = 200"
In your query inside jasper, you put it like this: "... select * from <anywhere> where $P!{paramWhere} ..." and it will magically work.

Can't declare a variable in ArangoDB

I'm using ArangoDB 3.4.6-1 and would like to delete vertices with AQL (as stated here) in online console.
In the first step according to the tutorial you are supposed to save your Edges into a variable. In my case the statement looks like this:
LET edgeKeys = (FOR v, e, p IN 1..100 INBOUND 'Node/N3' GRAPH 'graph' RETURN e._key)
The For itself without the brackets returns the correct result:
[
"E3"
]
Yet, running the whole statement with the brackets just throws the following error:
Query: AQL: syntax error, unexpected end of query string near ')' at position 1:83 (while parsing)
I tried using a comparable command with other graphs or other returned values and objects, but always get the same error.
So far I wasn't able to find a proper solution online. The tutorial provides the following example code (copied 1:1):
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
And I'm getting exactly the same error, it's not even able to check the collections.
What am I doing wrong?
Only defining a variable with LET is not a valid AQL statement.
From the AQL Syntax documentation:
An AQL query must either return a result (indicated by usage of the
RETURN keyword) or execute a data-modification operation (indicated by
usage of one of the keywords INSERT, UPDATE, REPLACE, REMOVE or
UPSERT). The AQL parser will return an error if it detects more than
one data-modification operation in the same query or if it cannot
figure out if the query is meant to be a data retrieval or a
modification operation.
Using the full AQL block that is stated in the tutorial the execution works as expected since the query is executing a data-modification with REMOVE in this case. Just a RETURN operation inside the LET variable declaration is not sufficient to run an AQL query. When removing the LET operation the query works as well since in this case the AQL query directly returns the result.
Complete AQL query:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
LET r = (FOR key IN edgeKeys REMOVE key IN knows)
REMOVE 'eve' IN persons
An additional RETURN also makes the query work:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
RETURN edgeKeys

Laravel 5.1 Invalid datetime format: 7 ERROR: invalid input syntax for type date error

I've been having trouble with eloquent that keeps returning error. Below is the query that i tried to run in laravel.
$actives = ProjectVersion::join('version_employees as ve', 've.report_id' ,'=', 'project_versions.id')
->join('employees as e', 've.employee_id', '=', 'e.id')
->whereBetween(\DB::raw("'1985-05-27'::date"),[
\DB::raw("to_date(timeline->>'start_time', 'YYYY-MM-DD')"),
\DB::raw("to_date(timeline->>'release_time', 'YYYY-MM-DD')")])
->groupBy('e.name')
->select(\DB::raw('count(e.id), e.name'))
->get();
Now this returns an error of
Invalid datetime format: 7 ERROR: invalid input syntax for type date: "to_date(timeline->>'start_time', 'YYYY-MM-DD')"
The full query returned by the error message is
SELECT count(e.id), e.name
FROM "project_versions" inner join "version_employees" as "ve" on "ve"."report_id" = "project_versions"."id" inner join "employees" as "e" on "ve"."employee_id" = "e"."id"
WHERE '1985-05-27'::date
BETWEEN to_date(timeline->>'start_time', 'YYYY-MM-DD')
AND to_date(timeline->>'release_time', 'YYYY-MM-DD')
GROUP BY "e"."name"
The thing is that when i run this query in pgadmin, it runs fine and returns the result that i wants.
I've been stuck for hours debugging this. Any idea on where the problem is ?
Well first off, it's not really eloquent in the way you're using it with all those Raw statements ;-)
Try using the Carbon class: Carbon::now()->toDateString() will return a date in the Y-m-d format.
For the where clause, if I'm understanding your query correctly, you can use 2 where clauses instead of the whereBetween with Raw SQL: ->where('start_time', '>', $start_time_preprocessed_by_carbon)->where('release_time', '<', $release_time_preprocessed_by_carbon)
And you seem to want the count which means you can end with a ->count() instead of a ->get()
I'd love to give you the full query but couldn't decipher it completely. However these implementations should give you a nudge in the right direction! They will help you abstract your query further to the point that Laravel's internal query generator will translate the code into the correct syntax for your database!

Mongodb, osm street maps, unique users

I imported a json file into my database, and the db itself works.
If use
print db.points.find_one()
my output looks like :
{u'id': u'342902', u'_id': ObjectId('555af76a029d3b1b0ff9a4be'), u'type': u'node', u'pos': [48.9979746, 8.3719741], u'created': {u'changeset': u'7105928', u'version': u'4', u'uid': u'163673', u'timestamp': u'2011-01-27T18:05:54Z', u'user': u'Free_Jan'}}
which is exactly what I want it to be. But if I want to get the number of distinct users:
print db.points.distinct({"created.user"}).length
I get the error:
TypeError: key must be an instance of basestring
which suggests that what I was searching for is not there (it clearly is as shown above). What am I missing here ?
You have a syntax error in your distinct clause - it should be .distinct("created.user") instead of .distinct({"created.user"}).
See the MongoDB documentation for distinct.
Edit: To return the length, therefore, something like:
print len(db.points.distinct("created.user"));
... or:
print db.points.distinct("created.user").__len__();
See this answer for getting the size of a list in Python.
Caveat: I'm no Python expert so the length bit might not be perfect...
I was facing the same problem.
print len(db.points.distinct("created.user")) works.
However,
print db.points.distinct("created.user").__len__();
does not.
The reason for the error is the braces:
db.points.distinct({"created.user"})
should read
db.points.distinct("created.user")
Also, '.length' is a mongo bash method. In pymongo, you use 'len()'. That is:
db.points.distinct({"created.user"}).length
should read
print len(db.points.distinct("created.user"))
unless you are using mongo bash/shell.