Solution was to remove the # from the colour and present as the original 
decimal provided by mapinfo easyloader. I have listed the whole style for any 
one who wants it.
Thanks for your help

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
xmlns="http://www.opengis.net/sld"; 
xmlns:ogc="http://www.opengis.net/ogc";
 xmlns:xlink="http://www.w3.org/1999/xlink"; 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation="http://www.opengis.net/sld 
http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd";>
  <NamedLayer>
    <Name>Mapinfo Line Colour setting</Name>
    <UserStyle>
      <Title>Colour settings</Title>
      <Abstract>Read pen and colour from MI_STYLE uploaded from mapinfo using 
Easyloader to postgis</Abstract>
  <FeatureTypeStyle>
     <Rule>
     <Name>Set Line Colour Thickness</Name>
     <ogc:Filter>
                <ogc:PropertyIsEqualTo>
                        <ogc:Function name="strSubstring">
                                <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
                                <ogc:Literal>0</ogc:Literal>
                                <ogc:Literal>3</ogc:Literal>
                        </ogc:Function>
                        <ogc:Literal>Pen</ogc:Literal>
                </ogc:PropertyIsEqualTo>
     </ogc:Filter>
    <LineSymbolizer>
      <Stroke>
        <CssParameter name="stroke">
          <ogc:Function name="parseInt">
            <ogc:Function name="strSubstring">
              <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
                          <ogc:Add>
                                <ogc:Function name="strLastIndexOf">
                                        
<ogc:PropertyName>MI_STYLE</ogc:PropertyName>
                                        <ogc:Literal>,</ogc:Literal>
                                </ogc:Function>
                          <ogc:Literal>2</ogc:Literal>
                          </ogc:Add>
              <ogc:Function name="strLastIndexOf">
                <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
                <ogc:Literal>)</ogc:Literal>
              </ogc:Function>                     
            </ogc:Function>
          </ogc:Function>
        </CssParameter>
        <CssParameter name="stroke-width">
          <ogc:Function name="parseInt">
            <ogc:Function name="strSubstring">
              <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
              <ogc:Literal>5</ogc:Literal>
              <ogc:Function name="strIndexOf">
                <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
                <ogc:Literal>,</ogc:Literal>
              </ogc:Function>
            </ogc:Function>
          </ogc:Function>
        </CssParameter>
      </Stroke>
       </LineSymbolizer>
     </Rule>
     <Rule>
     <Name>Default Colour Thickness</Name>
     <ogc:Filter>
                <ogc:PropertyIsNotEqualTo>
                        <ogc:Function name="strSubstring">
                                <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
                                <ogc:Literal>0</ogc:Literal>
                                <ogc:Literal>3</ogc:Literal>
                        </ogc:Function>
                        <ogc:Literal>Pen</ogc:Literal>
                </ogc:PropertyIsNotEqualTo>
    </ogc:Filter>
       <LineSymbolizer>
      <Stroke>
        <CssParameter name="stroke">#000000</CssParameter>
        <CssParameter name="stroke-width">1</CssParameter>
      </Stroke>
       </LineSymbolizer>
     </Rule>
   </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

-----Original Message-----
From: Milo van der Linden [mailto:m...@dogodigi.net] 
Sent: 30 October 2011 10:43
To: Andrea Aime
Cc: Andy Berry; geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] SLD files

The MapInfo color coding scheme is documented here:
http://georezo.net/jparis/MI_Enviro/Colors/color_models.htm#6-1%20R,G,B%20%3C%3E%20RGB

RGB = (65536 * R)  +  (256 * G)  +  B

With this formula, you should be able to get the R, G and B and
transform them to hex.

2011/10/30 Andrea Aime <andrea.a...@geo-solutions.it>:
> On Fri, Oct 28, 2011 at 2:12 PM, Andy Berry <andy.be...@wrexham.gov.uk> wrote:
>> I am trying to display lines with specific attributes contained in a  field
>>
>> The field (from Mapinfo) contains for example Pen(4, 2, 16711935)
>>
>> I will need to convert the 3rd number to a hex colour and the first to the
>> line thickness
>>
>> So far I have
>>
>>        <LineSymbolizer>
>>
>>                 <Stroke>
>>
>>                                 <CssParameter name="stroke">
>>
>>                                 #FF0000
>>
>>                                 </CssParameter>
>>
>>                                 <CssParameter name="stroke-width">
>>
>>                                 <ogc:Function name="strSubstring">
>>
>>
>> <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
>>
>>
>> <ogc:Literal>5</ogc:Literal>
>>
>>
>> <ogc:Function name="strIndexOf">
>>
>>
>>                 <ogc:PropertyName>MI_STYLE</ogc:PropertyName>
>>
>>
>> <ogc:Literal>,</ogc:Literal>
>>
>>
>> </ogc:Function>
>>
>>                                 </ogc:Function>
>>
>>                                 </CssParameter>
>>
>>                 </Stroke>
>>
>>        </LineSymbolizer>
>>
>> The difficulty is working out how to convert the number 1671168 to the hex
>> colour, in this case #FF0000. Has anyone done this before?
>
> I can't think of a good way to do that with the current toolset.
> I guess one would need some new filter functions that can do the parsing you
> need, that at the moment requires some java programming (we have been talking
> about having some scripting ability for a while, but so far nothing is
> evolved enough
> to ship with GeoServer, even if just as an extension)
>
> Cheers
> Andrea
>
> --
> -------------------------------------------------------
> Ing. Andrea Aime
> GeoSolutions S.A.S.
> Tech lead
>
> Via Poggio alle Viti 1187
> 55054  Massarosa (LU)
> Italy
>
> phone: +39 0584 962313
> fax:      +39 0584 962313
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://www.youtube.com/user/GeoSolutionsIT
> http://www.linkedin.com/in/andreaaime
> http://twitter.com/geowolf
>
> -------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Get your Android app more play: Bring it to the BlackBerry PlayBook
> in minutes. BlackBerry App World&#153; now supports Android&#153; Apps
> for the BlackBerry&reg; PlayBook&#153;. Discover just how easy and simple
> it is! http://p.sf.net/sfu/android-dev2dev
> _______________________________________________
> Geoserver-users mailing list
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>

Take a look - you can pay, report, request, have your say and find information 
online at www.wrexham.gov.uk.  

Save paper - think before you print!

This e-mail message and any attachments are intended solely for the individual 
or organisation to whom it is addressed. For full conditions in relation to 
content and use of this e-mail message and any attachments, please refer to 
http://www.wrexham.gov.uk/top_navigation/disclaimers.htm.

Mae'r neges e-bost hon ac unrhyw atodiadau wedi eu bwriadu ar gyfer yr unigolyn 
neu’r sefydliad y’i cyfeirir atynt yn unig.
Am yr amodau llawn ynglyn a chynnwys a defnyddio’r neges e-bost hon ac unrhyw 
atodiadau, cyfeiriwch at   
http://www.wrecsam.gov.uk/top_navigation/disclaimersw.htm.
------------------------------------------------------------------------------
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World&#153; now supports Android&#153; Apps 
for the BlackBerry&reg; PlayBook&#153;. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to