[OpenLayers-Dev] What is right format for WKT in OpenLayers
(comma white space vs. comma)?
Noli Sicad
nsicad at gmail.com
Thu Jun 16 01:08:02 EDT 2011
Hi Tim,
Thanks for your reply.
Yes, I found out the other day as well. That the Ctrl break (i.e
carraige control) were causing the problem.
Now, I got another lingering problem about the SQL spatial query,
table Html result that uses table html table td. The query result got
2 or more columns (e.g. name, AsText(Geometry)). The AsText(Geometry)
is the linestring. I need to put the AsText(Geometry) in the textarea.
I got all these jQuery suggestion from StackOverFlow and nothing work.
Here all these options below.
Any suggestion how I can accomplish this task of getting the
AsText(Geometry) text.
Thanks in Advance.
Noli
~~~~~~~~~~~~~~~~~~~~~~
<script>
$(document).ready(function() {
function GetNextChildText(tagToFind, valueToFind) {
var nextText = "";
$(tagToFind).each(function(i) {
if ($(this).text() == valueToFind) {
if ($(this).next() != null && $(this).next() != undefined) {
nextText = $(this).next().text();
}
}
});
return (nextText);
}
$('#wktAsTextInput').click(function(){
// var designationText = GetNextChildText('td', 'designation');
var asTextGeometryText = GetNextChildText('td', 'AsText(Geometry)');
$("#wktResult").text(asTextGeometryText);
});
$('#wkInputReal').click(function () {
$("table[id$='queryResults']
td:nth-child(1)").live('click',function(event) {
//Prevent the hyperlink to perform default behavior
event.preventDefault();
var $td= $(this).closest('tr').children('td');
var sr= $td.eq(0).text();
var name= $td.eq(1).text();
var asText= $td.eq(2).text();
$("#wktResult").text(asText);
});
$('#wkInputReal1').click(function () {
$("#queryResults td:nth-child(1)").click(function(event){
var $td= $(this).closest('tr').children('td');
var name= $td.eq(0).text(); //var sr= $td.eq(0).text();
var asText= $td.eq(1).text(); //var name= $td.eq(1).text();
//var city= $td.eq(2).text();
// $("#wktResult").val(asText); //
$("#txtName").val(name); // assigning the name to the textbox
$("#wktResult").text(asText); //
$("#txtName").text(name); // assigning the name to the textarea
$('#wkInput0').click(function () {
var table = document.getElementById('queryResults');
var asText = table.rows[1].cells[1].innerHTML;
$("#wktResult").text(asText);
});
$('#wktInput1').click(function() {
// $('#table tr').each(function() {
// var wktResultFirst = $(this).find("td:first").html();
// wktResultLast
$('#queryResults tr').each(function() {
var asText = $(this).find("td:last").html();
$("#wktResult").text(asText);
});
$('#wktInput2').click(function() {
var asText = $('th:contains("AsText(Geometry)")').text();
$("#wktResult").text(asText);
});
$('#wktInput3').click(function() {
var asText = $('table > td:last').text();
$("#wktResult").val(asText);
});
$('#wktInput4').click(function(){
var asText = $('tbody > tr:first > td:last').text();
$("#wktResult").val(asText);
});
});
</script>
On 6/16/11, Tim Schaub <tschaub at opengeo.org> wrote:
> On 6/9/11 2:24 AM, Noli Sicad wrote:
>> Hi,
>>
>> I ask this question a few hours ago about why the comma white space
>> format of my LINESTRING would not work in Openlayers WKT example and
>> I got the answer that my LINESTRING has wrong format i.e comma white
>> space format.
>>
>> What is the right format? It seems that Openlayers is not using the
>> right standard format for WKT, comma white instead it only use comma
>> in this example.
>>
>> http://dev.openlayers.org/releases/OpenLayers-2.6/examples/wkt.html
>>
>> This is standard WKT as result of Spatialite query. This one does not
>> work in the example
>>
>> LINESTRING(7.120068 43.583917, 7.120154
>> 43.583652, 7.120385 43.582716, 7.12039 43.582568, 7.120712 43.581511,
>> 7.120873 43.580718)
>
> The WKT parser is flexible with whitespace as long as you don't use
> multi-line strings. The string above looks like it contains newline
> characters.
>
> It looks like the WKT "spec" is not specific with regard to newlines (or
> tabs). Our parser can be made more lenient with a simple change.
>
> http://trac.osgeo.org/openlayers/attachment/ticket/3365/3365.patch
>
>> According to Robert in Openlayers-user one should use this format i.e
>> without white space.
>
> Again, it is not whitespace in general that is the problem, it is line
> breaking characters that are the problem.
>
> Tim
>
>> This format.
>>
>> LINESTRING(7.120068 43.583917,7.120154 43.583652,7.120385
>> 43.582716,7.12039 43.582568,7.120712 43.581511,7.120873 43.580718)
>>
>> However, according to Sandro, the author of Spatialite, the format is
>> not standard for WKT (Please see the forwarded mail below).
>>
>> Now, how can OpenLayers can use the standard WKT? My WKT i.e
>> LINESTRING is not hand written it is a result of Spatial query in
>> Spatialite.
>>
>> Any recent example to use the Standard WKT?
>>
>> Regards, Noli
>>
>>
>> ---------- Forwarded message ----------
>> From: "a.furieri"<a.furieri at lqt.it>
>> Date: Thu, 9 Jun 2011 00:59:40 -0700 (PDT)
>> Subject: [SpatiaLite-Users] Re: Is AsText result Spatialite query the
>> right format for WKT?
>> To: SpatiaLite Users<spatialite-users at googlegroups.com>
>>
>> Hi Noli,
>>
>> interesting question; and a really puzzling one.
>> as a general rule, any text parser I know simply
>> handles any whitespace as a "token delimiter",
>> thus allowing to insert an (infinitive) number
>> of whitespaces at any arbitrary position.
>>
>> So I always assumed that "number-comma-number" and
>> "number-[whitespace*]-comma-[whitespace*]-number"
>> would be exactly the same.
>>
>> And I found this in the MySQL Spatial own documentation:
>> http://dev.mysql.com/doc/refman/5.0/en/gis-wkt-format.html
>> LINESTRING(0 0, 10 10, 20 25, 50 60)
>> MULTIPOINT(0 0, 20 20, 60 60)
>> MULTILINESTRING((10 10, 20 20), (15 15, 30 15))
>>
>> And on Wikipedia I found:
>> http://en.wikipedia.org/wiki/Well-known_text
>> LINESTRING (30 10, 10 30, 40 40)
>> POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))
>> MULTIPOINT (10 40, 40 30, 20 20, 30 10)
>>
>> This is from OsGEO documentation:
>> http://www.osgeo.org/files/mapguide/docs/2.0/da/dc0/group___agf_text.htm
>> MULTIPOINT XY (
>> 0 0 , 1 1
>> )
>> POLYGON XY (
>> (1 -3, 4 -3, 4 -6, 1 -6, 1 -3),
>> (2 -4, 3 -4, 3 -5, 2 -5, 2 -4)
>> )
>>
>> And this is what I found while reading the 'Holy Bible',
>> i.e. the official OGC-SFS 1.1 spec:
>> http://portal.opengeospatial.org/files/?artifact_id=13228
>> 'LINESTRING( 67 13, 67 18, 59 18, 59
>> 13, 67 13 )'
>> 'POLYGON( ( 67 13, 67 18, 59 18, 59
>> 13, 67 13) )'
>> *** please note: this document in the most authoritative
>> *** of them all. For sure this one is the unique *real*
>> *** WKT specification, because it's the international
>> *** reference standard
>>
>> Accordingly to all the above examples, the "comma-whitespace"
>> notation absolutely seems to be a fully legitimate one.
>> So I suppose the issue you are noticing simply has to be
>> correctly classified as an OpenLayers own bug ;-)
>>
>> bye Sandro
>>
>
>
> --
> Tim Schaub
> OpenGeo - http://opengeo.org
> Enterprise support for open source geospatial.
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
More information about the Dev
mailing list