Skip to content

Expression grammar not allowing ! #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
loicgasser opened this issue Aug 3, 2017 · 4 comments
Closed

Expression grammar not allowing ! #25

loicgasser opened this issue Aug 3, 2017 · 4 comments

Comments

@loicgasser
Copy link
Contributor

layer = """                                                                     
LAYER                                                                           
    CONNECTION "user=user password=pass host=host dbname=mydb port=5432 options='-c client_encoding=utf-8'"
    CONNECTIONTYPE POSTGIS                                                      
    DATA "the_geom from  (SELECT *,mod(exposurecurve_level_db::integer, 5) as bgdi_modulo_5 FROM bazl.laermbelastungskataster_zivilflugplaetze ) as data using unique bgdi_id using srid=21781"
    NAME "ch.bazl.laermbelastungskataster-zivilflugplaetze_militaer-gesamt"        
    STATUS OFF                                                                  
    TEMPLATE "ttt"                                                              
    TYPE LINE                                                                   
    UNITS METERS                                                                
    LABELITEM exposurecurve_level_db                                            
    LABELMAXSCALEDENOM 20000                                                    
    FILTER "exposuregroup_exposuretype like 'OverallTrafficMilitary_Lr'"        
    METADATA                                                                    
        "ows_title"             "ch.bazl.laermbelastungskataster-zivilflugplaetze_militaer-gesamt"
        "ows_featureid"         "bgdi_id"                                       
        "wms_srs" "EPSG:21781 EPSG:2056 EPSG:4326 EPSG:3857 EPSG:3034 EPSG:3035 EPSG:4258 EPSG:31287 EPSG:25832 EPSG:25833 EPSG:31467 EPSG:32632 EPSG:32633"
        "ows_include_items"     "all"                                           
        "ows_exclude_items"     "bgdi_created_by,bgdi_modified_by,bgdi_created,bgdi_modified,bgdi_modulo_5"
    END                                                                         
    CLASS                                                                       
       NAME "bazl_overalltrafficmilitary_lr_5db"                                
       EXPRESSION ( [bgdi_modulo_5] eq 0 )                                      
       STYLE                                                                    
          COLOR 120 145 60                                                      
          WIDTH 2                                                               
       END                                                                      
       LABEL                                                                    
          COLOR 120 145 60                                                      
          OUTLINECOLOR 255 255 255                                              
          FONT "arialbd"                                                        
          TYPE truetype                                                         
          SIZE 10                                                               
          ANGLE FOLLOW                                                          
          MAXOVERLAPANGLE 40                                                    
          FORCE TRUE                                                            
       END                                                                      
    END                                                                         
                                                                                
    CLASS                                                                       
       NAME "bazl_overalltrafficmilitary_lr_1db"                                
       EXPRESSION ( [bgdi_modulo_5] != 0 )                                      
       STYLE                                                                    
          COLOR 120 145 60                                                      
          WIDTH 1                                                               
       END                                                                      
    END                                                                         
END                                                                                                                                               
"""                                                                         
import mappyfile                                                                
                                                                                
mappyfile.loads(layer)

the code sample above failes and complains about !
But this is still a valid EXPRESSION.
By the way thanks for this lib. ;)

See also:
http://mapserver.org/fr/mapfile/expressions.html#logical-expressions

While this clearly ok:
https://s.geo.admin.ch/74d42d8231

@geographika
Copy link
Owner

@loicgasser thanks for reporting this. I'll look at adding this into the grammar.
In the meantime does the alternative ne work for you?

@loicgasser
Copy link
Contributor Author

yes it does work with ne.
I've got something like a thousand layers, I am trying to lint with your tool. I may come up with other things. ;)

@geographika
Copy link
Owner

Just to add if you have very large mapfiles maybe try out the experimental lalr_first branch - it is several orders of magnitude faster, although will require falling back to earley in some cases.

@loicgasser
Copy link
Contributor Author

thanks for the tip, I'll try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants