GraphDB geof:distance between two points returns empty fields - geosparql - distance

I am using GraphDB and want to calculate the geof:distance between two points by using geosparql. The ?point and ?point2 are geometries and are structured like this "POINT(-77.050125 38.892086)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> . But the field dist in query remains empty for some reason. Why is that I cannot understand. I have enabled geosparql already.
My code follows:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://www.semanticweb.org/evangelos/ontologies/2019/2/untitled-ontology-2#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix unit: <http://qudt.org/vocab/unit#>
prefix sf: <http://www.opengis.net/ont/sf#>
prefix test24: <http://www.semanticweb.org/evangelos/ontologies/2019/2/untitled-ontology-2#>
SELECT ?point2 (geof:distance(?point, ?point2, unit:Kilometer) as ?dist)
WHERE
{
:MouseioMetaksisSoufliou :hasGPSCoordinates ?geom2.
?geom2 geo:asWKT ?point.
?geom3 geo:asWKT ?point2.
FILTER (?geom2 != ?geom3).
}
It kind worked with this. I think might the unit# ontology caused the problem
here is my working code
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://www.semanticweb.org/evangelos/ontologies/2019/2/untitled-ontology-2#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
prefix sf: <http://www.opengis.net/ont/sf#>
prefix test24: <http://www.semanticweb.org/evangelos/ontologies/2019/2/untitled-ontology-2#>
SELECT ?point10 ((geof:distance(?point10, ?point11, uom:metre) < 2000) as ?dist)
WHERE
{
:MouseioMetaksisSoufliou :hasGPSCoordinates ?geom2.
?geom2 geo:asWKT ?point.
?geom3 geo:asWKT ?point2.
FILTER(!sameTerm(?geom2, ?geom3)).
BIND(CONCAT("<http://www.opengis.net/def/crs/OGC/1.3/CRS84> ", STR(?point)) as ?point5)
BIND(CONCAT(STR(?point5), "^^geo:wktLiteral") as ?point10)
BIND(CONCAT("<http://www.opengis.net/def/crs/OGC/1.3/CRS84> ", STR(?point2)) as ?point6)
BIND(CONCAT(STR(?point6), "^^geo:wktLiteral") as ?point11)
}

Related

Passing list as an parameter in DRT template of Drools rule engine

I am trying to pass an array/list example- tag =["XYZ","ABC","PQR"] as an parameter to my template to generate drl using the java code and drools template API ObjectDataCompiler.
Template:
template header
tag
template "test for list"
rule "list_#{row.rowNumber}"
when
$list : List(${tag})
$value : String() from $list
then
System.out.println("yeah from template: "+ $value);
System.out.println("yeah from template: "+ $list.size());
System.out.println("yeah from template: "+ $list.get(1));
end
end template
Generate DRL file:
rule "list_0"
when
$list : List([XYZ, ABC, PQR])
$value : String() from $list
then
System.out.println("yeah from template: "+ $value);
System.out.println("yeah from template: "+ $list.size());
System.out.println("yeah from template: "+ $list.get(1));
end
Issue facing: I am unable to access the elements from the list. Is there anything that I am doing wrong?
There is no output printed for any of the System.out.println() why?
I tried evening using the tag[] in the template declaration, and in the template I have something like this "#{tag0}", when the rule is generated I get the values as like this "[XYZ" for the first and "PQR]" the last values.
Can you help me as I am getting an "[" "]" these square brackets for first and last values respectively?

Documentation does not show nested "One of" attributes correctly

This is my api blueprint file:
FORMAT: 1A
# system API
Example
## Clients [/clients]
### Add Client [POST]
+ Request
+ Attributes
+ Include (ClientDetails)
+ Response 200 (application/json)
# Data Structures
## Client (object)
+ name (string, required)
+ phone (string, required) - `E.164 format validated with the regex ^\+[1-9]\d{1,14}$`
+ tax_id (number)
## ClientDetails (object)
+ One Of
+ client (object)
+ Include (Client)
+ save_client: true (boolean)
It renders this Body as an example, which is what I expect:
"client": {
"name": "John Smith",
"phone": "+972504537442",
"tax_id": 515975597,
"save_client": true
}
However it renders the attributes section like this:

Mongodb '$where' query using javascript regex

I am trying to reproduce the REPLACE function in sql on mongodb.
My collection 'log' has this data in the 'text' field.
[01]ABC0007[0d0a]BB BABLOXC[0d0a]067989 PLPXBNS[0d0a02]BBR OIC002 L5U0/P AMD KAP 041800 T1200AND 2+00[0d0a0b03]
All I'm trying to do is remove the '[..]' using regex (javascript) and use contains('PLPXBNSBBR') like this so that the expression return true per the javadocs in mongo documentation.
This query below successfully works and returns the matching rows.
db.log.find({"$where":"return this.message.replace(new RegExp('0d0a02'),'').contains('PLPXBNS[]BBR') "});
However, I would need to remove the '[..]' and match like this PLPXBNSBBR.
These are the ones I tried unsuccessfully
db.log.find({"$where" : " return this.message.replace( new
RegExp('\[.*?\]', 'g'), '' ).contains('PLPXBNSBBR') " });
db.log.find({"$where" : " return this.message.replace( new
RegExp('/[(.*?)]', 'g'), '' ).contains('PLPXBNSBBR') " });
db.log.find({"$where" : " return this.message.replace( new
RegExp('//[.*//]'), '' ).contains('PLPXBNSBBR') " });
db.log.find({"$where" : " return this.message.replace( new
RegExp('[.*?]'), '' ).contains('PLPXBNSBBR') " });
From the earlier discussion it appears that if I can pass the pattern as /[[^]]+]/g, it should strip the [..] but it is not doing that and not returning the matching rows.
Okay, I was able to use chaining replace successfully to get my desired results.

How can I use a String in an URL?

I'm trying to create Web Service where I can send a stardog request using a HTTP GET method. My problem is that the stardog request are using a few symbol that aren't allowed in a URL, like ? or ; and I'm trying to not force the user to manually convert it to %3F or %3B.
So I want my URL to look like this :
localhost:8080/WebServiceTest/query?select="SELECT * WHERE {?s ?p ?o}"
My Jersey annotations are the following:
#GET
#Path("/query")
#Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public String execQuery(#QueryParam("select") String selectQuery, #QueryParam("update") String updateQuery) {
Does anyone know if this is possible? And if it is, how can I do that?
If you use Javascript/ECMAScript 5.1++ on client side you can convert a string to a uri string format. Use the method
encodeURIComponent(str);
which is explained here.
It is also possible to replace the ? ; chars by their %-represetation. (In the case of using cUrl)
(SPACE) ! " # $ % & ' ( ) * + , / : ;
%20 %21 %22 %23 %24 %25 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B
= ? # [ ]
%3D %3F %40 %5B %5D

JavaCC multiline comment in custom NetBeans plugin

I am having a problem with comments in creating custom file in NetBeans. I got two types of multiline comment types:
starting with /* and ending */
starting with <!-- and ending -->
MORE :
{
"/*": XSCRIPT_COMMENT
|
"<!--": XML_COMMENT
}
<XSCRIPT_COMMENT>
TOKEN :
{
<X_SCRIPT_COMMENT_END: "*/" > : DEFAULT
}
<XML_COMMENT>
TOKEN :
{
<XML_COMMENT_END: "-->" > : DEFAULT
}
<XSCRIPT_COMMENT,XML_COMMENT>
MORE :
{
< ~[] >
}
the problem is, that both multiline comments throws TokenMgrError when I write the initial part of comment (/* or <!--). The error occurs only when there is no ending part and lexer reaches end of file.
My goal is to create multiline comments which works similar to other comment types (When only initial part is written, the rest of document is comment type text).
Please excuse my english, not my native language.
For me, MartinZ's aswer also resolve an JavaCC lexical problem.
{ <COMMENT: "/*" (~["*"])* |
"/*" (~["*"])* "*" (~["/"])* |
"/*" (~["*"])* "*" (~["/"])* "/" > }
One way to do it is to use a single regular expression to match comments. For example a /* .. */
multiline comment can be matched by
"/*" (("*")* ~["*"])* ("*" ("*")* "/"?)?
Here I made the final "*/" optional. (The best way to come up with this sort of regular expression, in my experience, is to convert an NDFA to an RE, if you know how to do that.)
Another way to do it is to allow an empty string to end a comment. Add these two rules.
<XML_COMMENT> TOKEN : { <XML_COMMENT_END: "" > : DEFAULT }
<XSCRIPT_COMMENT> TOKEN : { <X_SCRIPT_COMMENT_END: "" > : DEFAULT }
Solved by different regular expression. First I created deterministic automaton just with pen and paper, but graphic view is always the best.
<XSCRIPT_COMMENT:
"/*" (~["*"])*
|
"/*" (~["*"])* "*" (~["/"])*
|
"/*" (~["*"])* "*" (~["/"])* "/"
>
<XML_COMMENT:
"<!--" (~["-"])*
|
"<!--" (~["-"])* "-" (~["-"])*
|
"<!--" (~["-"])* "-" (~["-"])* "-" (~[">"])*
|
"<!--" (~["-"])* "-" (~["-"])* "-" (~[">"])* ">"
>
I realize that both expressions aren't from minimized DFA, but like this it is easier to understand.