Changeset 267

Show
Ignore:
Timestamp:
05/30/10 23:40:08 (21 months ago)
Author:
ol
Message:

Add reverse axis notion in ows_srs. Rewrite ows_srs_set_from_srsname function. Use Reverse axis GML3 notion in FE Enveloppe

Location:
trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/fe/fe_spatial_ops.c

    r262 r267  
    8282{ 
    8383    xmlChar *content, *srsname; 
    84     buffer *srid, *name, *tmp; 
     84    buffer *srid, *name, *tmp, *srsname_b; 
    8585    list *coord_min, *coord_max, *coord_pair; 
    8686    int srid_int; 
     87    bool ret; 
    8788    ows_bbox *bbox; 
     89    ows_srs *s=NULL; 
    8890 
    8991    assert(o != NULL); 
     
    105107    srsname = xmlGetProp(n, (xmlChar *) "srsName"); 
    106108 
     109 
    107110    if (srsname != NULL) { 
    108         if (!check_regexp((char *) srsname, srid->buf)) { 
     111        srsname_b = buffer_init(); 
     112        buffer_add_str(srsname_b, (char *) srsname); 
     113        s = ows_srs_init(); 
     114 
     115        if (!ows_srs_set_from_srsname(o, s, srsname_b)) { 
    109116            fe->error_code = FE_ERROR_SRS; 
    110117            xmlFree(srsname); 
     118            buffer_free(srsname_b); 
    111119            buffer_free(name); 
    112120            buffer_free(srid); 
     121            ows_srs_free(s); 
    113122            return fe->sql; 
    114123        } 
     124 
     125        xmlFree(srsname); 
     126        buffer_free(srsname_b); 
    115127    } 
    116128 
     
    136148 
    137149        coord_max = list_explode_str(' ', (char *) content); 
     150 
     151         
    138152    } 
    139153    /* GML2 */ 
     
    153167 
    154168    buffer_free(name); 
    155     xmlFree(srsname); 
    156169    xmlFree(content); 
    157170    buffer_free(srid); 
     
    159172    /* return the polygon's coordinates matching the bbox */ 
    160173    bbox = ows_bbox_init(); 
    161     if (!ows_bbox_set(o, bbox, atof(coord_min->first->value->buf), 
     174    if (s && s->is_reverse_axis) { 
     175        ret = ows_bbox_set(o, bbox, 
     176                          atof(coord_min->first->next->value->buf), 
     177                          atof(coord_min->first->value->buf), 
     178                          atof(coord_max->first->next->value->buf), 
     179                          atof(coord_max->first->value->buf), 
     180                          srid_int); 
     181    } else { 
     182        ret = ows_bbox_set(o, bbox, 
     183                          atof(coord_min->first->value->buf), 
    162184                          atof(coord_min->first->next->value->buf), 
    163185                          atof(coord_max->first->value->buf), 
    164186                          atof(coord_max->first->next->value->buf), 
    165                           srid_int)) { 
     187                          srid_int); 
     188    } 
     189 
     190    if (!ret) { 
    166191        fe->error_code = FE_ERROR_BBOX; 
    167192        list_free(coord_min); 
    168193        list_free(coord_max); 
    169194        ows_bbox_free(bbox); 
     195        if (s) ows_srs_free(s); 
    170196 
    171197        return fe->sql; 
     
    177203    ows_bbox_to_query(o, bbox, fe->sql); 
    178204    ows_bbox_free(bbox); 
     205    if (s) ows_srs_free(s); 
    179206 
    180207    return fe->sql; 
  • trunk/src/ows/ows.h

    r262 r267  
    123123 
    124124typedef struct Ows_srs { 
    125         int srid; 
    126         buffer * auth_name; 
    127         int auth_srid; 
    128     bool is_unit_degree; 
     125    int srid; 
     126    buffer * auth_name; 
     127    int auth_srid; 
     128    bool is_degree; 
     129    bool is_reverse_axis; 
    129130} ows_srs; 
    130131 
  • trunk/src/ows/ows_srs.c

    r189 r267  
    4444    c->auth_name = buffer_init(); 
    4545    c->auth_srid = 0; 
    46     c->is_unit_degree = true; 
     46    c->is_degree = true; 
     47    c->is_reverse_axis = false; 
    4748 
    4849    return c; 
     
    7980    fprintf(output, " auth_srid: %i\n", c->auth_srid); 
    8081 
    81     if (c->is_unit_degree) 
    82         fprintf(output, " is_unit_degree: true\n]\n"); 
     82    if (c->is_degree) 
     83        fprintf(output, " is_degree: true\n]\n"); 
    8384    else 
    84         fprintf(output, " is_unit_degree: false\n]\n"); 
     85        fprintf(output, " is_degree: false\n]\n"); 
     86 
     87    if (c->is_reverse_axis) 
     88        fprintf(output, " is_reverse_axis: true\n]\n"); 
     89    else 
     90        fprintf(output, " is_reverse_axis: false\n]\n"); 
    8591} 
    8692#endif 
     
    126132    /* Such a way to know if units is meter or degree */ 
    127133    if (atoi(PQgetvalue(res, 0, 1)) == 0) 
    128         c->is_unit_degree = true; 
     134        c->is_degree = true; 
    129135    else 
    130         c->is_unit_degree = false; 
     136        c->is_degree = false; 
    131137 
    132138    PQclear(res); 
     
    150156        buffer_empty(s->auth_name); 
    151157        s->auth_srid = 0; 
    152         s->is_unit_degree = true; 
     158        s->is_degree = true; 
     159        s->is_reverse_axis=false; 
    153160 
    154161        return true; 
     
    177184    /* Such a way to know if units is meter or degree */ 
    178185    if (atoi(PQgetvalue(res, 0, 2)) == 0) 
    179         s->is_unit_degree = true; 
     186        s->is_degree = true; 
    180187    else 
    181         s->is_unit_degree = false; 
     188        s->is_degree = false; 
    182189 
    183190    PQclear(res); 
     
    193200    int srid = -1; 
    194201    list * tokens = NULL; 
     202    char sep; 
    195203 
    196204    assert(o != NULL); 
     
    198206    assert(srsname != NULL); 
    199207 
    200     /* Severals formats are available, cf WFS 1.1.0 -> 9.2 (p36) 
    201      * See also RFC 5165 <http://tools.ietf.org/html/rfc5165> 
    202      * 
    203      * x-ogc should become obsolete a day, and only urn:ogc should remain 
     208    /* Severals srsName formats are available... 
     209     *  cf WFS 1.1.0 -> 9.2 (p36) 
     210     *  cf ISO 19142 -> 7.9.2.4.4 (p34) 
     211     *  cf RFC 5165 <http://tools.ietf.org/html/rfc5165> 
     212     *  cf CITE WFS-1.1 (GetFeature-tc17.2) 
    204213     */ 
    205     if (strncmp(srsname->buf, "http://www.opengis.net/gml/srs/epsg.xml#", 40) == 0) 
    206         tokens = list_explode('#', srsname); 
    207     else if (strncmp(srsname->buf,   "http://www.epsg.org/", 20) == 0) 
    208         tokens = list_explode('/', srsname); 
    209     else if (strncmp(srsname->buf, "EPSG:", 5) == 0 
    210             || strncmp(srsname->buf, "urn:EPSG:geographicCRC:", 23) == 0 
    211             || strncmp(srsname->buf, "urn:ogc:def:crs:EPSG:", 21) == 0 
    212             || strncmp(srsname->buf, "urn:x-ogc:def:crs:EPSG:", 23) == 0)  
    213         tokens = list_explode(':', srsname); 
    214  
    215     /* FIXME add here on in OWS request part, more strict regex tests, to 
    216      * be sure that srsname value pattern is right 
    217      * 
    218      * Remember that urn:ogc and urn:x-ogc ones could have an optional  
    219      * version number 
     214 
     215     /* SRS pattern like:    EPSG:4326 
     216                             urn:EPSG:geographicCRS:4326 
     217                             urn:ogc:def:crs:EPSG:4326 
     218                             urn:ogc:def:crs:EPSG::4326 
     219                             urn:ogc:def:crs:EPSG:6.6:4326 
     220                             urn:x-ogc:def:crs:EPSG:6.6:4326 
     221                             http://www.opengis.net/gml/srs/epsg.xml#4326 
     222                             http://www.epsg.org/6.11.2/4326 
    220223     */ 
    221      
     224 
     225     if (!strncmp((char *) srsname->buf,        "EPSG:", 5)) { 
     226         sep = ':'; 
     227         s->is_reverse_axis = false; 
     228 
     229     } else if (!strncmp((char *) srsname->buf, "urn:ogc:def:crs:EPSG:", 21) 
     230             || !strncmp((char *) srsname->buf, "urn:x-ogc:def:crs:EPSG:", 23) 
     231             || !strncmp((char *) srsname->buf, "urn:EPSG:geographicCRS:", 23)) { 
     232         sep = ':'; 
     233         s->is_reverse_axis = true; 
     234 
     235     } else if (!strncmp((char *) srsname->buf, "http://www.opengis.net/gml/srs/epsg.xml#", 40)) { 
     236         sep = '#'; 
     237         s->is_reverse_axis = false; 
     238 
     239     } else if (!strncmp((char *) srsname->buf, "http://www.epsg.org/", 20)) { 
     240         sep = '/'; 
     241         s->is_reverse_axis = false; 
     242 
     243     } else return false; 
     244 
     245     tokens = list_explode(sep, srsname); 
     246 
    222247    if (tokens->last->value && tokens->last->value->buf) 
    223         srid = atoi(tokens->last->value->buf); 
     248        srid = atoi(tokens->last->value->buf);  /* TODO Add regexp isdigit test */ 
     249    else return false; 
    224250 
    225251    list_free(tokens); 
     252 
    226253    return ows_srs_set_from_srid(o, s, srid); 
    227254} 
  • trunk/src/wfs/wfs_get_feature.c

    r263 r267  
    391391        /* execute the sql request */ 
    392392        res = PQexec(o->pg, ln->value->buf); 
     393buffer_flush(ln->value, stderr); 
    393394 
    394395        if (PQresultStatus(res) != PGRES_TUPLES_OK) { 
     
    482483                } 
    483484 
    484                 if ((wr->srs != NULL && !wr->srs->is_unit_degree) ||  
     485                if ((wr->srs != NULL && !wr->srs->is_degree) ||  
    485486                        (wr->srs == NULL && ows_srs_meter_units(o, layer_name))) 
    486487                    buffer_add_int(select, o->meter_precision);  
     
    510511                } 
    511512 
    512                 if ((wr->srs != NULL && !wr->srs->is_unit_degree) ||  
     513                if ((wr->srs != NULL && !wr->srs->is_degree) ||  
    513514                        (wr->srs == NULL && ows_srs_meter_units(o, layer_name))) { 
    514515                    buffer_add_int(select, o->meter_precision); 
     
    539540                } 
    540541 
    541                 if ((wr->srs != NULL && !wr->srs->is_unit_degree) ||  
     542                if ((wr->srs != NULL && !wr->srs->is_degree) ||  
    542543                        (wr->srs == NULL && ows_srs_meter_units(o, layer_name))) 
    543544                    buffer_add_int(select, o->meter_precision);