New Provider

48 views
Skip to first unread message

CARLOS GARCIA

unread,
Feb 11, 2017, 11:30:13 AM2/11/17
to MapSurfer.NET
Recently I begin to use MapSurfer.NET. I noticed the lack of Oracle Provider, so I made a new implementation 

The provider works good and acomplish all the stuf.

But when I tried to display on a map, nothings happend, doesn´t draw anything

Any advice? does anyone create a new provider?

Regards

Carlos Garcia

Runge

unread,
Feb 13, 2017, 8:31:39 AM2/13/17
to MapSurfer.NET
Hi Carlos,


Recently I begin to use MapSurfer.NET. I noticed the lack of Oracle Provider, so I made a new implementation
The provider works good and acomplish all the stuf.
Glad to here about new data source provider for Oracle Database.


But when I tried to display on a map, nothings happend, doesn´t draw anything
There might several issues to that.
1. You have not added any styling (Rules, Symbolizers) to your layer.
2. You are viewing the map out of the extent of your data set.


Any advice? does anyone create a new provider?

How did you create new provider? Have you attached an instance of your data provider to a StyledLayer?

Best regards,
Max

CARLOS GARCIA

unread,
Feb 13, 2017, 11:52:43 AM2/13/17
to MapSurfer.NET
It's something like that:

            m_dsProvider = new MapSurfer.Data.OracleDB.OracleDBProvider("GISPETI", "ESTACION_O", "SHAPE", "");
            m_dsProvider.Initialize(new MapSurfer.Configuration.ParameterCollection() { new MapSurfer.Configuration.Parameter() { Name = "ConnectionString", Value = "Data Source=gis101;User Id=gispeti;Password=peti101; Connection Timeout = 60; " } }, "");
            Envelope env = m_dsProvider.GetExtent();
            MapSurfer.Layers.StyledLayer layer = new MapSurfer.Layers.StyledLayer("estacion");
            layer.DataSource = (DataSourceProvider)m_dsProvider;
            layer.Styles = new MapSurfer.Styling.FeatureTypeStyleCollection();
            MapSurfer.Styling.FeatureTypeStyle style = new MapSurfer.Styling.FeatureTypeStyle();
            style.Rules = new MapSurfer.Styling.RuleCollection();
            MapSurfer.Styling.Rule rule = new MapSurfer.Styling.Rule();
            rule.Symbolizers = new MapSurfer.Styling.SymbolizerCollection();
            MapSurfer.Styling.PointSymbolizer symbol = new MapSurfer.Styling.PointSymbolizer();
            
            rule.Symbolizers.Add(symbol);
            style.Rules.Add(rule);
            layer.Styles.Add(style);
            
            frmMapView mv = new DatasourceViewer.frmMapView();
            mv.layer = layer;
            mv.ShowDialog();

1. It's point data, so I'd tried with point defaults
2. The same occurs with polygon
3. I think that it's something defining the symbolization
4. But wich is definitely wrong its the Exten property of layer (null). Doesn't know where to initilalize

Runge

unread,
Feb 13, 2017, 2:52:11 PM2/13/17
to MapSurfer.NET
In general, you are on the right way. There are some missing parts that do not allow you to see a desired result.
The most crucial issue is null value of GetExtent method in your provider. This method is either empty or not implemented at all. In order MapSurfer.NET could properly visualize data, it is required to return the extent and projection of the data set.
Normally, GetExtent is implemented as follows:

private Envelope _extent;

public Envelope GetExtent()
{
    if (_extent == null)
    {
        double minx, miny, max, maxy;
         using (OracleConnection conn = new OracleConnection (true))
        {
           OracleCommand cmd = conn.CreateCommand();
            cmd.CommandText = "SELECT minx, miny, maxx, maxy FROM " + tablename;   // this a rough idea, check Oracle Spatial functions to extract extent of the data set from a table.
   
           OracleDataReader r = cmd.ExecuteReader();

           while (r.Read())
             {
                 if (!(r.IsDBNull(0) || r.IsDBNull(1) || r.IsDBNull(2) || r.IsDBNull(3)))
                 {
                     minx = r.GetDouble(0);
                     miny = r.GetDouble(1);
                     maxx = r.GetDouble(2);
                     maxy= r.GetDouble(3);
            }
          }     
         _extent = new Envelope(minx,miny,maxx,maxy);
     }
    
     return _extent;
}

For some really huge tables, the computation of the table's extent might take several seconds or even minutes. To avoid this delays, you can add an additional parameter into Initialize method such as

m_dsProvider.Initialize(new MapSurfer.Configuration.
ParameterCollection() { new MapSurfer.Configuration.Parameter() { Name = "ConnectionString", Value = "Data Source=gis101;User Id=gispeti;Password=peti101; Connection Timeout = 60; " } }, "",
new MapSurfer.Configuration.Parameter() { Name = "Extent", Value = "0,0,180,90" }};)
In Initialize method, you just create _extent object from the values given above.

Second, you symbolization is not complete. In PointSymbolizer you have to specify a GraphicSymbol through
 ExternalGraphicSymbol imageSymbol = new  ExternalGraphicSymbol ();
imageSymbol.Path =  "D:\image.png";
symbol.Graphic.GraphicSymbols.Add(imageSymbol );
    
  

CARLOS GARCIA

unread,
Feb 13, 2017, 5:36:18 PM2/13/17
to MapSurfer.NET
The extent always return a good one.
I'd change all the code (using parameter collection to initializa provider). Y think that the problem may be in de DataReader
MapSurfer.Data.OracleDB.rar

Runge

unread,
Feb 14, 2017, 6:47:27 AM2/14/17
to MapSurfer.NET
Hi Carlos,

I looked through your code and did not find any issues in it.
Would that be possible to get a temporal access to your Oracle server for test purposes, so I could take a deeper look in debug mode?

Actually, I have my own implementation of the provider, but it was not finished, because I do not have an Oracle database installed anymore.
Reply all
Reply to author
Forward
0 new messages