mapObject serialization in C# (variant)

11 messages Options
Embed this post
Permalink
BrainDrain

mapObject serialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
Is there any 'standart' fast(!) way/method to serialize (xml/json/other markup) mapObj in C#? I need it for using server mapObj as JSON on rich client app running on browser. Look at my method (using reflection):

public static ListDictionary PartialSerialize(object instance, Stack callerTypes, Type[] excludeTypes)
        {
            ListDictionary result = new ListDictionary();
            object val;

            callerTypes.Push(instance.GetType());
            PropertyInfo[] pis = instance.GetType().GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                if (pi.PropertyType.IsSerializable && !pi.PropertyType.IsArray)
                    result[pi.Name] = pi.GetValue(instance, new object[0]);
                else
                {
                    //preventing useless nesting
                    if (!callerTypes.Contains(pi.PropertyType) && !((IList)excludeTypes).Contains(pi.PropertyType))
                    {
                        val = pi.GetValue(instance, new object[0]);
                        if (val != null)
                            result[pi.Name] = PartialSerialize(val, callerTypes, excludeTypes);
                    }
                }
            }
            callerTypes.Pop();
            return result;
        }
...
So I can convert mapObj on serever to hashtable automatically an then populate JSON object
(still need to call explicitly getLayer, getClass etc., but this is not a problem):
...
layers[i].Properties = Tools.PartialSerialize(layer, new Stack(), new Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
...
classes[j].Properties = Tools.PartialSerialize(layerClass, new Stack(), new Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj), typeof(colorObj)});
...
styles[k].Properties = Tools.PartialSerialize(classStyle, new Stack(), new Type[2]{typeof(hashTableObj), typeof(colorObj)});
...
mapStub.Properties = Tools.PartialSerialize(map, new Stack(), new Type[11] { typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj), typeof(labelCacheObj), typeof(outputFormatObj[]), typeof(queryMapObj), typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj), typeof(colorObj), typeof(legendObj)});
...
JavaScriptSerializer class object allows to perform convertion to client
More often I use script method in my web service that can do it behind the scenes.

How do you do such kind of operation?
Tamas Szekeres

Re: mapObject serialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
Hi,

MapServer currently doesn`t support any other persitence
representation than the mapfiles. There have been some initial plans
related to an XML format in this list, but no one had any motivation
to implement that.
So I think the best what you can do at the moment is to use reflection
to access the properties along with some other members of the objects
and serialize the values manually.

Best regards,

Tamas


2008/6/9 BrainDrain <[hidden email]>:

>
> Is there any 'standart' fast(!) way/method to serialize (xml/json/other
> markup) mapObj in C#? I need it for using server mapObj as JSON on rich
> client app running on browser. Look at my method (using reflection):
>
> public static ListDictionary PartialSerialize(object instance, Stack
> callerTypes, Type[] excludeTypes)
>        {
>            ListDictionary result = new ListDictionary();
>            object val;
>
>            callerTypes.Push(instance.GetType());
>            PropertyInfo[] pis = instance.GetType().GetProperties();
>            foreach (PropertyInfo pi in pis)
>            {
>                if (pi.PropertyType.IsSerializable &&
> !pi.PropertyType.IsArray)
>                    result[pi.Name] = pi.GetValue(instance, new object[0]);
>                else
>                {
>                    //preventing useless nesting
>                    if (!callerTypes.Contains(pi.PropertyType) &&
> !((IList)excludeTypes).Contains(pi.PropertyType))
>                    {
>                        val = pi.GetValue(instance, new object[0]);
>                        if (val != null)
>                            result[pi.Name] = PartialSerialize(val,
> callerTypes, excludeTypes);
>                    }
>                }
>            }
>            callerTypes.Pop();
>            return result;
>        }
> ...
> So I can convert mapObj on serever to hashtable automatically an then
> populate JSON object
> (still need to call explicitly getLayer, getClass etc., but this is not a
> problem):
> ...
> layers[i].Properties = Tools.PartialSerialize(layer, new Stack(), new
> Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
> ...
> classes[j].Properties = Tools.PartialSerialize(layerClass, new Stack(), new
> Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj),
> typeof(colorObj)});
> ...
> styles[k].Properties = Tools.PartialSerialize(classStyle, new Stack(), new
> Type[2]{typeof(hashTableObj), typeof(colorObj)});
> ...
> mapStub.Properties = Tools.PartialSerialize(map, new Stack(), new Type[11] {
> typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj),
> typeof(labelCacheObj), typeof(outputFormatObj[]), typeof(queryMapObj),
> typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj),
> typeof(colorObj), typeof(legendObj)});
> ...
> JavaScriptSerializer class object allows to perform convertion to client
> More often I use script method in my web service that can do it behind the
> scenes.
>
> How do you do such kind of operation?
> --
> View this message in context: http://www.nabble.com/mapObject-serialization-in-C--%28variant%29-tp17739919p17739919.html
> Sent from the Mapserver - User mailing list archive at Nabble.com.
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Bob Basques

Re: MapFile2XML conversion - WAS: mapObject serialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
All,
 
We've been pondering some sort of alternative to the Mapfiles for a few years now.  A preferable approach would be something that could be stored in a DB in some fashion for querying/assembly processes.  It seems on the surface like a DB schema could be developed to handle the MapFile storage aspects.
 
A first step would be in how to best approach moving into an XML way of life for the MapFiles.  Would it make any sense in the beginning to just build a MapFile2XML convertor (I would imagine this would be needed before anyone would sign up for XML) and once something like this is a state close to production, the innards of MapServer would then be made to parse the XML directly? 
 
Another approach might be to do something like MapFile2SQL first, and then the MapFile2XML.  This might save some time and seem like it would make standardization easier, since it would need to be inside of the DB fist.
 
Has anyone tried putting together any requirements list along these lines at all?  Is it going to be something where we just need to jump in and build something even if it might be a wrong approach to begin with?
 
This thread just got me thinking is all . . .you know how dangerous that can be . . . :c)
 
bobb
 


>>> "Tamas Szekeres" <[hidden email]> wrote:
Hi,

MapServer currently doesn`t support any other persitence
representation than the mapfiles. There have been some initial plans
related to an XML format in this list, but no one had any motivation
to implement that.
So I think the best what you can do at the moment is to use reflection
to access the properties along with some other members of the objects
and serialize the values manually.

Best regards,

Tamas


2008/6/9 BrainDrain <[hidden email]>:

>
> Is there any 'standart' fast(!) way/method to serialize (xml/json/other
> markup) mapObj in C#? I need it for using server mapObj as JSON on rich
> client app running on browser. Look at my method (using reflection):
>
> public static ListDictionary PartialSerialize(object instance, Stack
> callerTypes, Type[] excludeTypes)
>        {
>            ListDictionary result = new ListDictionary();
>            object val;
>
>            callerTypes.Push(instance.GetType());
>            PropertyInfo[] pis = instance.GetType().GetProperties();
>            foreach (PropertyInfo pi in pis)
>            {
>                if (pi.PropertyType.IsSerializable &&
> !pi.PropertyType.IsArray)
>                    result[pi.Name] = pi.GetValue(instance, new object[0]);
>                else
>                {
>                    //preventing useless nesting
>                    if (!callerTypes.Contains(pi.PropertyType) &&
> !((IList)excludeTypes).Contains(pi.PropertyType))
>                    {
>                        val = pi.GetValue(instance, new object[0]);
>                        if (val != null)
>                            result[pi.Name] = PartialSerialize(val,
> callerTypes, excludeTypes);
>                    }
>                }
>            }
>            callerTypes.Pop();
>            return result;
>        }
> ...
> So I can convert mapObj on serever to hashtable automatically an then
> populate JSON object
> (still need to call explicitly getLayer, getClass etc., but this is not a
> problem):
> ...
> layers[i].Properties = Tools.PartialSerialize(layer, new Stack(), new
> Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
> ...
> classes[j].Properties = Tools.PartialSerialize(layerClass, new Stack(), new
> Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj),
> typeof(colorObj)});
> ...
> styles[k].Properties = Tools.PartialSerialize(classStyle, new Stack(), new
> Type[2]{typeof(hashTableObj), typeof(colorObj)});
> ...
> mapStub.Properties = Tools.PartialSerialize(map, new Stack(), new Type[11] {
> typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj),
> typeof(labelCacheObj), typeof(outputFormatObj[]), typeof(queryMapObj),
> typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj),
> typeof(colorObj), typeof(legendObj)});
> ...
> JavaScriptSerializer class object allows to perform convertion to client
> More often I use script method in my web service that can do it behind the
> scenes.
>
> How do you do such kind of operation?
> --
> View this message in context: http://www.nabble.com/mapObject-serialization-in-C--(variant)-tp17739919p17739919.html
> Sent from the Mapserver - User mailing list archive at Nabble.com.
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Barend Kobben

Re: MapFile2XML conversion - WAS: mapObject serialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
Hi Bob,

YES, by all means do move to XML. I think this would be a very important
step forward (and my first guess is it would be not too complicated, but you
never know...).

I do see how some might be attracted to having an DB storage too, but I
would urge you to always have that as an alternative, not as instead-of:
keep the main configuration mechanism (XML-)file based! In many use cases
there's no need for a DB and that would mean you'd have tho have a DB plus
all its hassle, only for the configuration part. Also the current file-base
config is ideal in situations were many people need to work on the one MS,
such as in our educational setup, where we have many students working on
their own config files in their private dirs, and they don't need to touch
the 'main' MS setup on the server.

Actually, what are your reasons for preferring an SQL sdolution over the
file based one...?


--
Barend Köbben
International Institute for Geo-Information
Sciences and Earth Observation (ITC)
PO Box 6
7500AA Enschede, The Netherlands
+31 (0)53 4874253



On 10-06-08 20:30, "Bob Basques" <[hidden email]> wrote:

> All,
>  
> We've been pondering some sort of alternative to the Mapfiles for a few years
> now.  A preferable approach would be something that could be stored in a DB in
> some fashion for querying/assembly processes.  It seems on the surface like a
> DB schema could be developed to handle the MapFile storage aspects.
>  
> A first step would be in how to best approach moving into an XML way of life
> for the MapFiles.  Would it make any sense in the beginning to just build a
> MapFile2XML convertor (I would imagine this would be needed before anyone
> would sign up for XML) and once something like this is a state close to
> production, the innards of MapServer would then be made to parse the XML
> directly?  
>  
> Another approach might be to do something like MapFile2SQL first, and then the
> MapFile2XML.  This might save some time and seem like it would make
> standardization easier, since it would need to be inside of the DB fist.
>  
> Has anyone tried putting together any requirements list along these lines at
> all?  Is it going to be something where we just need to jump in and build
> something even if it might be a wrong approach to begin with?
>  
> This thread just got me thinking is all . . .you know how dangerous that can
> be . . . :c)
>  
> bobb
>  
>
>
>>>> "Tamas Szekeres" <[hidden email]> wrote:
> Hi,
>
> MapServer currently doesn`t support any other persitence
> representation than the mapfiles. There have been some initial plans
> related to an XML format in this list, but no one had any motivation
> to implement that.
> So I think the best what you can do at the moment is to use reflection
> to access the properties along with some other members of the objects
> and serialize the values manually.
>
> Best regards,
>
> Tamas
>
>
> 2008/6/9 BrainDrain <[hidden email]>:
>>
>> Is there any 'standart' fast(!) way/method to serialize (xml/json/other
>> markup) mapObj in C#? I need it for using server mapObj as JSON on rich
>> client app running on browser. Look at my method (using reflection):
>>
>> public static ListDictionary PartialSerialize(object instance, Stack
>> callerTypes, Type[] excludeTypes)
>>        {
>>            ListDictionary result = new ListDictionary();
>>            object val;
>>
>>            callerTypes.Push(instance.GetType());
>>            PropertyInfo[] pis = instance.GetType().GetProperties();
>>            foreach (PropertyInfo pi in pis)
>>            {
>>                if (pi.PropertyType.IsSerializable &&
>> !pi.PropertyType.IsArray)
>>                    result[pi.Name] = pi.GetValue(instance, new object[0]);
>>                else
>>                {
>>                    //preventing useless nesting
>>                    if (!callerTypes.Contains(pi.PropertyType) &&
>> !((IList)excludeTypes).Contains(pi.PropertyType))
>>                    {
>>                        val = pi.GetValue(instance, new object[0]);
>>                        if (val != null)
>>                            result[pi.Name] = PartialSerialize(val,
>> callerTypes, excludeTypes);
>>                    }
>>                }
>>            }
>>            callerTypes.Pop();
>>            return result;
>>        }
>> ...
>> So I can convert mapObj on serever to hashtable automatically an then
>> populate JSON object
>> (still need to call explicitly getLayer, getClass etc., but this is not a
>> problem):
>> ...
>> layers[i].Properties = Tools.PartialSerialize(layer, new Stack(), new
>> Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
>> ...
>> classes[j].Properties = Tools.PartialSerialize(layerClass, new Stack(), new
>> Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj),
>> typeof(colorObj)});
>> ...
>> styles[k].Properties = Tools.PartialSerialize(classStyle, new Stack(), new
>> Type[2]{typeof(hashTableObj), typeof(colorObj)});
>> ...
>> mapStub.Properties = Tools.PartialSerialize(map, new Stack(), new Type[11] {
>> typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj),
>> typeof(labelCacheObj), typeof(outputFormatObj[]), typeof(queryMapObj),
>> typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj),
>> typeof(colorObj), typeof(legendObj)});
>> ...
>> JavaScriptSerializer class object allows to perform convertion to client
>> More often I use script method in my web service that can do it behind the
>> scenes.
>>
>> How do you do such kind of operation?
>> --
>> View this message in context:
>> http://www.nabble.com/mapObject-serialization-in-C--%28variant%29-tp17739919p
>> 17739919.html
>> Sent from the Mapserver - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> mapserver-users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users

International Institute for Geo-Information Science and Earth Observation (ITC)
Chamber of Commerce: 410 27 560

E-mail disclaimer
The information in this e-mail, including any attachments, is intended for the addressee only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or action in relation to the content of this information is strictly prohibited. If you have received this e-mail by mistake, please delete the message and any attachment and inform the sender by return e-mail. ITC accepts no liability for any error or omission in the message content or for damage of any kind that may arise as a result of e-mail transmission.
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Rahkonen Jukka

Re: MapFile2XML conversion - WAS: mapObjectserialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
Hi,

Oh no, please do not move to XML as the only alternative, at least not without making a very-easy-to-use XML-Mapfile editor for mortals like me with the same.

-Jukka Rahkonen-

> -----Alkuperäinen viesti-----
> Lähettäjä: [hidden email]
> [mailto:[hidden email]] Puolesta
> Barend Kobben
> Lähetetty: 11. kesäkuuta 2008 10:41
> Vastaanottaja: Bob Basques; [hidden email]
> Aihe: Re: [MAPSERVER-USERS] MapFile2XML conversion - WAS:
> mapObjectserialization in C# (variant)
>
> Hi Bob,
>
> YES, by all means do move to XML. I think this would be a
> very important step forward (and my first guess is it would
> be not too complicated, but you never know...).
>
> I do see how some might be attracted to having an DB storage
> too, but I would urge you to always have that as an
> alternative, not as instead-of:
> keep the main configuration mechanism (XML-)file based! In
> many use cases there's no need for a DB and that would mean
> you'd have tho have a DB plus all its hassle, only for the
> configuration part. Also the current file-base config is
> ideal in situations were many people need to work on the one
> MS, such as in our educational setup, where we have many
> students working on their own config files in their private
> dirs, and they don't need to touch the 'main' MS setup on the server.
>
> Actually, what are your reasons for preferring an SQL
> sdolution over the file based one...?
>
>
> --
> Barend Köbben
> International Institute for Geo-Information Sciences and
> Earth Observation (ITC) PO Box 6 7500AA Enschede, The Netherlands
> +31 (0)53 4874253
>
>
>
> On 10-06-08 20:30, "Bob Basques" <[hidden email]> wrote:
>
> > All,
> >  
> > We've been pondering some sort of alternative to the
> Mapfiles for a few years
> > now.  A preferable approach would be something that could
> be stored in a DB in
> > some fashion for querying/assembly processes.  It seems on
> the surface like a
> > DB schema could be developed to handle the MapFile storage aspects.
> >  
> > A first step would be in how to best approach moving into
> an XML way of life
> > for the MapFiles.  Would it make any sense in the beginning
> to just build a
> > MapFile2XML convertor (I would imagine this would be needed
> before anyone
> > would sign up for XML) and once something like this is a
> state close to
> > production, the innards of MapServer would then be made to
> parse the XML
> > directly?  
> >  
> > Another approach might be to do something like MapFile2SQL
> first, and then the
> > MapFile2XML.  This might save some time and seem like it would make
> > standardization easier, since it would need to be inside of
> the DB fist.
> >  
> > Has anyone tried putting together any requirements list
> along these lines at
> > all?  Is it going to be something where we just need to
> jump in and build
> > something even if it might be a wrong approach to begin with?
> >  
> > This thread just got me thinking is all . . .you know how
> dangerous that can
> > be . . . :c)
> >  
> > bobb
> >  
> >
> >
> >>>> "Tamas Szekeres" <[hidden email]> wrote:
> > Hi,
> >
> > MapServer currently doesn`t support any other persitence
> > representation than the mapfiles. There have been some initial plans
> > related to an XML format in this list, but no one had any motivation
> > to implement that.
> > So I think the best what you can do at the moment is to use
> reflection
> > to access the properties along with some other members of
> the objects
> > and serialize the values manually.
> >
> > Best regards,
> >
> > Tamas
> >
> >
> > 2008/6/9 BrainDrain <[hidden email]>:
> >>
> >> Is there any 'standart' fast(!) way/method to serialize
> (xml/json/other
> >> markup) mapObj in C#? I need it for using server mapObj as
> JSON on rich
> >> client app running on browser. Look at my method (using
> reflection):
> >>
> >> public static ListDictionary PartialSerialize(object
> instance, Stack
> >> callerTypes, Type[] excludeTypes)
> >>        {
> >>            ListDictionary result = new ListDictionary();
> >>            object val;
> >>
> >>            callerTypes.Push(instance.GetType());
> >>            PropertyInfo[] pis = instance.GetType().GetProperties();
> >>            foreach (PropertyInfo pi in pis)
> >>            {
> >>                if (pi.PropertyType.IsSerializable &&
> >> !pi.PropertyType.IsArray)
> >>                    result[pi.Name] = pi.GetValue(instance,
> new object[0]);
> >>                else
> >>                {
> >>                    //preventing useless nesting
> >>                    if (!callerTypes.Contains(pi.PropertyType) &&
> >> !((IList)excludeTypes).Contains(pi.PropertyType))
> >>                    {
> >>                        val = pi.GetValue(instance, new object[0]);
> >>                        if (val != null)
> >>                            result[pi.Name] = PartialSerialize(val,
> >> callerTypes, excludeTypes);
> >>                    }
> >>                }
> >>            }
> >>            callerTypes.Pop();
> >>            return result;
> >>        }
> >> ...
> >> So I can convert mapObj on serever to hashtable
> automatically an then
> >> populate JSON object
> >> (still need to call explicitly getLayer, getClass etc.,
> but this is not a
> >> problem):
> >> ...
> >> layers[i].Properties = Tools.PartialSerialize(layer, new
> Stack(), new
> >> Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
> >> ...
> >> classes[j].Properties = Tools.PartialSerialize(layerClass,
> new Stack(), new
> >> Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj),
> >> typeof(colorObj)});
> >> ...
> >> styles[k].Properties = Tools.PartialSerialize(classStyle,
> new Stack(), new
> >> Type[2]{typeof(hashTableObj), typeof(colorObj)});
> >> ...
> >> mapStub.Properties = Tools.PartialSerialize(map, new
> Stack(), new Type[11] {
> >> typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj),
> >> typeof(labelCacheObj), typeof(outputFormatObj[]),
> typeof(queryMapObj),
> >> typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj),
> >> typeof(colorObj), typeof(legendObj)});
> >> ...
> >> JavaScriptSerializer class object allows to perform
> convertion to client
> >> More often I use script method in my web service that can
> do it behind the
> >> scenes.
> >>
> >> How do you do such kind of operation?
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/mapObject-serialization-in-C--%28variant
> %29-tp17739919p
> >> 17739919.html
> >> Sent from the Mapserver - User mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> mapserver-users mailing list
> >> [hidden email]
> >> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >>
> > _______________________________________________
> > mapserver-users mailing list
> > [hidden email]
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> > _______________________________________________
> > mapserver-users mailing list
> > [hidden email]
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
> International Institute for Geo-Information Science and Earth
> Observation (ITC)
> Chamber of Commerce: 410 27 560
>
> E-mail disclaimer
> The information in this e-mail, including any attachments, is
> intended for the addressee only. If you are not the intended
> recipient, you are hereby notified that any disclosure,
> copying, distribution or action in relation to the content of
> this information is strictly prohibited. If you have received
> this e-mail by mistake, please delete the message and any
> attachment and inform the sender by return e-mail. ITC
> accepts no liability for any error or omission in the message
> content or for damage of any kind that may arise as a result
> of e-mail transmission.
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Piero Cavalieri

RE: mapObject serialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
In reply to this post by Tamas Szekeres
I don't know C# mapscript, but are you sure you need to serialize the whole mapObj? At the and I think that in your client, you will use: image, reference map and scalebar urls, an html (or xml) representation of the legend...so why don't to serialize a custom object which contains only these things ? I do so, without using mapscript, it's simple...

Cheers
 Piero

> -----Original Message-----
> From: [hidden email] [mailto:mapserver-users-
> [hidden email]] On Behalf Of Tamas Szekeres
> Sent: martedì 10 giugno 2008 19:58
> To: BrainDrain
> Cc: [hidden email]
> Subject: Re: [MAPSERVER-USERS] mapObject serialization in C# (variant)
>
> Hi,
>
> MapServer currently doesn`t support any other persitence
> representation than the mapfiles. There have been some initial plans
> related to an XML format in this list, but no one had any motivation
> to implement that.
> So I think the best what you can do at the moment is to use reflection
> to access the properties along with some other members of the objects
> and serialize the values manually.
>
> Best regards,
>
> Tamas
>
>
> 2008/6/9 BrainDrain <[hidden email]>:
> >
> > Is there any 'standart' fast(!) way/method to serialize (xml/json/other
> > markup) mapObj in C#? I need it for using server mapObj as JSON on rich
> > client app running on browser. Look at my method (using reflection):
> >
> > public static ListDictionary PartialSerialize(object instance, Stack
> > callerTypes, Type[] excludeTypes)
> >        {
> >            ListDictionary result = new ListDictionary();
> >            object val;
> >
> >            callerTypes.Push(instance.GetType());
> >            PropertyInfo[] pis = instance.GetType().GetProperties();
> >            foreach (PropertyInfo pi in pis)
> >            {
> >                if (pi.PropertyType.IsSerializable &&
> > !pi.PropertyType.IsArray)
> >                    result[pi.Name] = pi.GetValue(instance, new
> object[0]);
> >                else
> >                {
> >                    //preventing useless nesting
> >                    if (!callerTypes.Contains(pi.PropertyType) &&
> > !((IList)excludeTypes).Contains(pi.PropertyType))
> >                    {
> >                        val = pi.GetValue(instance, new object[0]);
> >                        if (val != null)
> >                            result[pi.Name] = PartialSerialize(val,
> > callerTypes, excludeTypes);
> >                    }
> >                }
> >            }
> >            callerTypes.Pop();
> >            return result;
> >        }
> > ...
> > So I can convert mapObj on serever to hashtable automatically an then
> > populate JSON object
> > (still need to call explicitly getLayer, getClass etc., but this is not
> a
> > problem):
> > ...
> > layers[i].Properties = Tools.PartialSerialize(layer, new Stack(), new
> > Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
> > ...
> > classes[j].Properties = Tools.PartialSerialize(layerClass, new Stack(),
> new
> > Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj),
> > typeof(colorObj)});
> > ...
> > styles[k].Properties = Tools.PartialSerialize(classStyle, new Stack(),
> new
> > Type[2]{typeof(hashTableObj), typeof(colorObj)});
> > ...
> > mapStub.Properties = Tools.PartialSerialize(map, new Stack(), new
> Type[11] {
> > typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj),
> > typeof(labelCacheObj), typeof(outputFormatObj[]), typeof(queryMapObj),
> > typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj),
> > typeof(colorObj), typeof(legendObj)});
> > ...
> > JavaScriptSerializer class object allows to perform convertion to client
> > More often I use script method in my web service that can do it behind
> the
> > scenes.
> >
> > How do you do such kind of operation?
> > --
> > View this message in context: http://www.nabble.com/mapObject-
> serialization-in-C--%28variant%29-tp17739919p17739919.html
> > Sent from the Mapserver - User mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > mapserver-users mailing list
> > [hidden email]
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
John Callahan

Re: MapFile2XML conversion

Reply Threaded More More options
Print post
Permalink
In reply to this post by Barend Kobben
Some javascript/style in this post has been disabled (why?)
Is it possible to allow MapServer to use KML, or a variation thereof?   I really don't what would be entailed.  For example, KML can store coordinates for displaying vectors, which would be pointless in our context.  Can KML point to shapefiles or tables for vectors like it can point to TIFs for rasters?  If so, it seems like the infrastructure (styling, external editing packages, viewers, conversion tools, wide adoption) is already there to build on.  Can we pull pieces from KML to make it easier for people to adopt without learning a new structure?

+1 on keeping the configuration maps as file based.  Databases are great for many reasons but add an entirely new level of complexity (and points of failure) for any application.

- John
****************************************
John Callahan
Geospatial Application Developer

Delaware Geological Survey
University of Delaware
227 Academy St, Newark DE 19716-7501
Tel: (302) 831-3584  

Email: [hidden email]
http://www.dgs.udel.edu
****************************************


Barend Kobben wrote:
Hi Bob,

YES, by all means do move to XML. I think this would be a very important
step forward (and my first guess is it would be not too complicated, but you
never know...). 

I do see how some might be attracted to having an DB storage too, but I
would urge you to always have that as an alternative, not as instead-of:
keep the main configuration mechanism (XML-)file based! In many use cases
there's no need for a DB and that would mean you'd have tho have a DB plus
all its hassle, only for the configuration part. Also the current file-base
config is ideal in situations were many people need to work on the one MS,
such as in our educational setup, where we have many students working on
their own config files in their private dirs, and they don't need to touch
the 'main' MS setup on the server.

Actually, what are your reasons for preferring an SQL sdolution over the
file based one...?


  


Bob Basques wrote:
All,
 
We've been pondering some sort of alternative to the Mapfiles for a few years now.  A preferable approach would be something that could be stored in a DB in some fashion for querying/assembly processes.  It seems on the surface like a DB schema could be developed to handle the MapFile storage aspects.
 
A first step would be in how to best approach moving into an XML way of life for the MapFiles.  Would it make any sense in the beginning to just build a MapFile2XML convertor (I would imagine this would be needed before anyone would sign up for XML) and once something like this is a state close to production, the innards of MapServer would then be made to parse the XML directly? 
 
Another approach might be to do something like MapFile2SQL first, and then the MapFile2XML.  This might save some time and seem like it would make standardization easier, since it would need to be inside of the DB fist.
 
Has anyone tried putting together any requirements list along these lines at all?  Is it going to be something where we just need to jump in and build something even if it might be a wrong approach to begin with?
 
This thread just got me thinking is all . . .you know how dangerous that can be . . . :c)
 
bobb
 


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Tamas Szekeres

Re: MapFile2XML conversion - WAS: mapObject serialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
In reply to this post by Bob Basques
Hi Bob and All,

I would support having an interface in mapserver that would provide
low level access to the object hierarchy, like:

typedef struct object_info {
  char* name;
  void* value;
  char* type;
  int index;
} objectInfo;

objectInfo* GetNextSubItem(objectInfo* object);

By using this, each persistence provider (MapFile/XML/JSON) could go
through the object hierarchy easily
In order to support reading the files, the mapObj properties in the
hierarchy could also be set in an unique manner, like:

int AddSubItem(objectInfo parent, objectInfo child);

We should also utilize an msIO like functionality so that the
providers would support reading from and writing to various kind of
streams/storage types.

We should probably switch to the -dev list with further implementation details.

Best regards,

Tamas



2008/6/10 Bob Basques <[hidden email]>:

> All,
>
> We've been pondering some sort of alternative to the Mapfiles for a few
> years now.  A preferable approach would be something that could be stored in
> a DB in some fashion for querying/assembly processes.  It seems on the
> surface like a DB schema could be developed to handle the MapFile storage
> aspects.
>
> A first step would be in how to best approach moving into an XML way of life
> for the MapFiles.  Would it make any sense in the beginning to just build a
> MapFile2XML convertor (I would imagine this would be needed before anyone
> would sign up for XML) and once something like this is a state close to
> production, the innards of MapServer would then be made to parse the XML
> directly?
>
> Another approach might be to do something like MapFile2SQL first, and then
> the MapFile2XML.  This might save some time and seem like it would make
> standardization easier, since it would need to be inside of the DB fist.
>
> Has anyone tried putting together any requirements list along these lines at
> all?  Is it going to be something where we just need to jump in and build
> something even if it might be a wrong approach to begin with?
>
> This thread just got me thinking is all . . .you know how dangerous that can
> be . . . :c)
>
> bobb
>
>
>>>> "Tamas Szekeres" <[hidden email]> wrote:
> Hi,
>
> MapServer currently doesn`t support any other persitence
> representation than the mapfiles. There have been some initial plans
> related to an XML format in this list, but no one had any motivation
> to implement that.
> So I think the best what you can do at the moment is to use reflection
> to access the properties along with some other members of the objects
> and serialize the values manually.
>
> Best regards,
>
> Tamas
>
>
> 2008/6/9 BrainDrain <[hidden email]>:
>>
>> Is there any 'standart' fast(!) way/method to serialize (xml/json/other
>> markup) mapObj in C#? I need it for using server mapObj as JSON on rich
>> client app running on browser. Look at my method (using reflection):
>>
>> public static ListDictionary PartialSerialize(object instance, Stack
>> callerTypes, Type[] excludeTypes)
>>        {
>>            ListDictionary result = new ListDictionary();
>>            object val;
>>
>>            callerTypes.Push(instance.GetType());
>>            PropertyInfo[] pis = instance.GetType().GetProperties();
>>            foreach (PropertyInfo pi in pis)
>>            {
>>                if (pi.PropertyType.IsSerializable &&
>> !pi.PropertyType.IsArray)
>>                    result[pi.Name] = pi.GetValue(instance, new object[0]);
>>                else
>>                {
>>                    //preventing useless nesting
>>                    if (!callerTypes.Contains(pi.PropertyType) &&
>> !((IList)excludeTypes).Contains(pi.PropertyType))
>>                    {
>>                        val = pi.GetValue(instance, new object[0]);
>>                        if (val != null)
>>                            result[pi.Name] = PartialSerialize(val,
>> callerTypes, excludeTypes);
>>                    }
>>                }
>>            }
>>            callerTypes.Pop();
>>            return result;
>>        }
>> ...
>> So I can convert mapObj on serever to hashtable automatically an then
>> populate JSON object
>> (still need to call explicitly getLayer, getClass etc., but this is not a
>> problem):
>> ...
>> layers[i].Properties = Tools.PartialSerialize(layer, new Stack(), new
>> Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
>> ...
>> classes[j].Properties = Tools.PartialSerialize(layerClass, new Stack(),
>> new
>> Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj),
>> typeof(colorObj)});
>> ...
>> styles[k].Properties = Tools.PartialSerialize(classStyle, new Stack(), new
>> Type[2]{typeof(hashTableObj), typeof(colorObj)});
>> ...
>> mapStub.Properties = Tools.PartialSerialize(map, new Stack(), new Type[11]
>> {
>> typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj),
>> typeof(labelCacheObj), typeof(outputFormatObj[]), typeof(queryMapObj),
>> typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj),
>> typeof(colorObj), typeof(legendObj)});
>> ...
>> JavaScriptSerializer class object allows to perform convertion to client
>> More often I use script method in my web service that can do it behind the
>> scenes.
>>
>> How do you do such kind of operation?
>> --
>> View this message in context:
>> http://www.nabble.com/mapObject-serialization-in-C--(variant)-tp17739919p17739919.html
>> Sent from the Mapserver - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> mapserver-users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Bob Basques

Re: MapFile2XML conversion

Reply Threaded More More options
Print post
Permalink
In reply to this post by Barend Kobben
Some javascript/style in this post has been disabled (why?)
John,
 
You're starting to think about two different applications of XML.  I was interested in setting up the XML to reflect the typical MapFile contents and use the XML for the Map generation out of MapServer.  KML is a output format option, that would be output by MapServer, (possibly using this new XML MapServer control) to format the KML output.
 
I would still tend to keep the configurations as file based as well, the DB approach just aloows for much more flexibilty for those hardcore programmers, and the MapFiles, don't input into a DB very easily.
 
bobb


>>> John Callahan <[hidden email]> wrote:
Is it possible to allow MapServer to use KML, or a variation thereof?  
I really don't what would be entailed.  For example, KML can store
coordinates for displaying vectors, which would be pointless in our
context.  Can KML point to shapefiles or tables for vectors like it can
point to TIFs for rasters?  If so, it seems like the infrastructure
(styling, external editing packages, viewers, conversion tools, wide
adoption) is already there to build on.  Can we pull pieces from KML to
make it easier for people to adopt without learning a new structure?

+1 on keeping the configuration maps as file based.  Databases are great
for many reasons but add an entirely new level of complexity (and points
of failure) for any application.

- John

****************************************
John Callahan
Geospatial Application Developer

Delaware Geological Survey
University of Delaware
227 Academy St, Newark DE 19716-7501
Tel: (302) 831-3584 

Email: [hidden email]
http://www.dgs.udel.edu
****************************************



Barend Kobben wrote:

> Hi Bob,
>
> YES, by all means do move to XML. I think this would be a very important
> step forward (and my first guess is it would be not too complicated, but you
> never know...).
>
> I do see how some might be attracted to having an DB storage too, but I
> would urge you to always have that as an alternative, not as instead-of:
> keep the main configuration mechanism (XML-)file based! In many use cases
> there's no need for a DB and that would mean you'd have tho have a DB plus
> all its hassle, only for the configuration part. Also the current file-base
> config is ideal in situations were many people need to work on the one MS,
> such as in our educational setup, where we have many students working on
> their own config files in their private dirs, and they don't need to touch
> the 'main' MS setup on the server.
>
> Actually, what are your reasons for preferring an SQL sdolution over the
> file based one...?
>
>
>  

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
BrainDrain

RE: mapObject serialization in C# (variant)

Reply Threaded More More options
Print post
Permalink
In reply to this post by Piero Cavalieri
I use excludeTypes parameter to exclude some properies of mapObj and child-objects. (see example above)
I decided to do so because I wanted to keep unambiguous conformity between my custom representation and mapserver object automatically, I wanted to minimize 'interface' changes.
XML - it will be great, in conjunction with xslt. I love xpath - it brings db aspect (you're talking about) to life.
I can write xml from mapObj with the same method but with other serializer (there are many .net object->db mappers available, including object->xml). And it is possible to read mapObj xml via xslt transformation producing normal map text file config (not implemented yet, but it will be sufficiently simple).

Piero Cavalieri wrote:
I don't know C# mapscript, but are you sure you need to serialize the whole mapObj? At the and I think that in your client, you will use: image, reference map and scalebar urls, an html (or xml) representation of the legend...so why don't to serialize a custom object which contains only these things ? I do so, without using mapscript, it's simple...

Cheers
 Piero

> -----Original Message-----
> From: mapserver-users-bounces@lists.osgeo.org [mailto:mapserver-users-
> bounces@lists.osgeo.org] On Behalf Of Tamas Szekeres
> Sent: martedì 10 giugno 2008 19:58
> To: BrainDrain
> Cc: mapserver-users@lists.osgeo.org
> Subject: Re: [MAPSERVER-USERS] mapObject serialization in C# (variant)
>
> Hi,
>
> MapServer currently doesn`t support any other persitence
> representation than the mapfiles. There have been some initial plans
> related to an XML format in this list, but no one had any motivation
> to implement that.
> So I think the best what you can do at the moment is to use reflection
> to access the properties along with some other members of the objects
> and serialize the values manually.
>
> Best regards,
>
> Tamas
>
>
> 2008/6/9 BrainDrain <paulborodaev@gmail.com>:
> >
> > Is there any 'standart' fast(!) way/method to serialize (xml/json/other
> > markup) mapObj in C#? I need it for using server mapObj as JSON on rich
> > client app running on browser. Look at my method (using reflection):
> >
> > public static ListDictionary PartialSerialize(object instance, Stack
> > callerTypes, Type[] excludeTypes)
> >        {
> >            ListDictionary result = new ListDictionary();
> >            object val;
> >
> >            callerTypes.Push(instance.GetType());
> >            PropertyInfo[] pis = instance.GetType().GetProperties();
> >            foreach (PropertyInfo pi in pis)
> >            {
> >                if (pi.PropertyType.IsSerializable &&
> > !pi.PropertyType.IsArray)
> >                    result[pi.Name] = pi.GetValue(instance, new
> object[0]);
> >                else
> >                {
> >                    //preventing useless nesting
> >                    if (!callerTypes.Contains(pi.PropertyType) &&
> > !((IList)excludeTypes).Contains(pi.PropertyType))
> >                    {
> >                        val = pi.GetValue(instance, new object[0]);
> >                        if (val != null)
> >                            result[pi.Name] = PartialSerialize(val,
> > callerTypes, excludeTypes);
> >                    }
> >                }
> >            }
> >            callerTypes.Pop();
> >            return result;
> >        }
> > ...
> > So I can convert mapObj on serever to hashtable automatically an then
> > populate JSON object
> > (still need to call explicitly getLayer, getClass etc., but this is not
> a
> > problem):
> > ...
> > layers[i].Properties = Tools.PartialSerialize(layer, new Stack(), new
> > Type[3] { typeof(mapObj), typeof(hashTableObj), typeof(colorObj)});
> > ...
> > classes[j].Properties = Tools.PartialSerialize(layerClass, new Stack(),
> new
> > Type[4] { typeof(layerObj), typeof(labelObj), typeof(hashTableObj),
> > typeof(colorObj)});
> > ...
> > styles[k].Properties = Tools.PartialSerialize(classStyle, new Stack(),
> new
> > Type[2]{typeof(hashTableObj), typeof(colorObj)});
> > ...
> > mapStub.Properties = Tools.PartialSerialize(map, new Stack(), new
> Type[11] {
> > typeof(labelObj), typeof(hashTableObj), typeof(fontSetObj),
> > typeof(labelCacheObj), typeof(outputFormatObj[]), typeof(queryMapObj),
> > typeof(referenceMapObj), typeof(scalebarObj), typeof(symbolSetObj),
> > typeof(colorObj), typeof(legendObj)});
> > ...
> > JavaScriptSerializer class object allows to perform convertion to client
> > More often I use script method in my web service that can do it behind
> the
> > scenes.
> >
> > How do you do such kind of operation?
> > --
> > View this message in context: http://www.nabble.com/mapObject-
> serialization-in-C--%28variant%29-tp17739919p17739919.html
> > Sent from the Mapserver - User mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users@lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >
> _______________________________________________
> mapserver-users mailing list
> mapserver-users@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
John Callahan

Re: MapFile2XML conversion

Reply Threaded More More options
Print post
Permalink
In reply to this post by Bob Basques
Some javascript/style in this post has been disabled (why?)
I know what you mean about different applications of XML.  However, can a single file or format serve both needs?  KML is an output format and used in many programs but it can be viewed as a map description format as well: it can point to multiple datasets, access dynamic web services and WMS, adds style information, screen overlays, and more.  Aside from inclusion of coordinates/geometry of vectors data instead of referencing a vector dataset, KML seems to do accomplish similar tasks as map files.   I've always thought KML becomes difficult to share when locally referencing large rasters; KML as input to a map server engine would solve that.

It would be huge stretch to make something like this work but the lure of incorporating the successes of KML into an open source project (as something more than just an output format) just got me wondering.   Even converting KML files to map files (placemarks/paths/polygons become shapefiles) may be beneficial.  Just some thoughts...

- John

****************************************
John Callahan
Geospatial Application Developer

Delaware Geological Survey
University of Delaware
227 Academy St, Newark DE 19716-7501
Tel: (302) 831-3584  

Email: [hidden email]
http://www.dgs.udel.edu
****************************************


Bob Basques wrote:
John,
 
You're starting to think about two different applications of XML.  I was interested in setting up the XML to reflect the typical MapFile contents and use the XML for the Map generation out of MapServer.  KML is a output format option, that would be output by MapServer, (possibly using this new XML MapServer control) to format the KML output.
 
I would still tend to keep the configurations as file based as well, the DB approach just aloows for much more flexibilty for those hardcore programmers, and the MapFiles, don't input into a DB very easily.
 
bobb


>>> John Callahan [hidden email] wrote:
Is it possible to allow MapServer to use KML, or a variation thereof?  
I really don't what would be entailed.  For example, KML can store
coordinates for displaying vectors, which would be pointless in our
context.  Can KML point to shapefiles or tables for vectors like it can
point to TIFs for rasters?  If so, it seems like the infrastructure
(styling, external editing packages, viewers, conversion tools, wide
adoption) is already there to build on.  Can we pull pieces from KML to
make it easier for people to adopt without learning a new structure?

+1 on keeping the configuration maps as file based.  Databases are great
for many reasons but add an entirely new level of complexity (and points
of failure) for any application.

- John

****************************************
John Callahan
Geospatial Application Developer

Delaware Geological Survey
University of Delaware
227 Academy St, Newark DE 19716-7501
Tel: (302) 831-3584 

Email: [hidden email]
http://www.dgs.udel.edu
****************************************



Barend Kobben wrote:
> Hi Bob,
>
> YES, by all means do move to XML. I think this would be a very important
> step forward (and my first guess is it would be not too complicated, but you
> never know...).
>
> I do see how some might be attracted to having an DB storage too, but I
> would urge you to always have that as an alternative, not as instead-of:
> keep the main configuration mechanism (XML-)file based! In many use cases
> there's no need for a DB and that would mean you'd have tho have a DB plus
> all its hassle, only for the configuration part. Also the current file-base
> config is ideal in situations were many people need to work on the one MS,
> such as in our educational setup, where we have many students working on
> their own config files in their private dirs, and they don't need to touch
> the 'main' MS setup on the server.
>
> Actually, what are your reasons for preferring an SQL sdolution over the
> file based one...?
>
>
>  

_______________________________________________ mapserver-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users