| 1 | = MaestroAPI 4.x API comparison = |
| 2 | |
| 3 | Maestro 4.x has fundamental API changes from 2.x. This table outlines the main classes/interfaces in 2.x and their equivalents in 3.x (NOTE: This is not a comprehensive list, and the list has not been verified yet). The list also contains small code samples, that will late be pit in a separate section. |
| 4 | Also see the '''[wiki:maestro/MaestroAPI/Maestro3ApiComparisons API 3.x Comparisons guide]''' for more info. |
| 5 | |
| 6 | {{{ |
| 7 | #!html |
| 8 | <table> |
| 9 | <tr><th>v2.x </th><th>v4.x</th></tr> |
| 10 | <tr> |
| 11 | <td> |
| 12 | IServerConnection con = new HttpServerConnection(host, sessionid, <span style="color:#FF0000;">"en"</span>, true);</td> |
| 13 | <td> |
| 14 | <span style="color:#3399FF;">IServerConnection</span> con = |
| 15 | <span style="color:#3399FF;">ConnectionProviderRegistry</span>.CreateConnection(<span style="color:#FF0000;">"Maestro.Http"</span>, <span style="color:#FF0000;">"Url="</span> + host + |
| 16 | <span style="color:#FF0000;">";SessionId="</span> + sessionid + <span style="color:#FF0000;">";Locale=en;AllowUntestedVersion=true"</span>);</td> |
| 17 | </tr> |
| 18 | <tr> |
| 19 | <td> |
| 20 | <span style="color:#3399FF;">RuntimeMap</span> map = con.GetRuntimeMap(mapid);<br /> |
| 21 | </td> |
| 22 | <td> |
| 23 | <span style="color:#3399FF;">IMappingService</span> mapSvc = (<span style="color:#3399FF;">IMappingService</span>)con.GetService((<span style="color:#0000FF;">int</span>)<span style="color:#3399FF;">ServiceType</span>.Mapping);<br /> |
| 24 | <span style="color:#3399FF;">RuntimeMap</span> map = mapSvc.OpenMap(mapid); |
| 25 | </td> |
| 26 | </tr> |
| 27 | <tr> |
| 28 | <td> |
| 29 | <span style="color:#0000FF;">new</span> IMapDefinition()</td> |
| 30 | <td> |
| 31 | ObjectFactory.CreateMapDefinition(con, map.Name);</td> |
| 32 | </tr> |
| 33 | <tr> |
| 34 | <td> |
| 35 | <span style="color:#3399FF;">RuntimeMap</span> map = new RuntimeMap(mdef);</td> |
| 36 | <td> |
| 37 | <span style="color:#3399FF;">IMapDefinition</span> mapDef = (<span style="color:#3399FF;">IMapDefinition</span>)con.ResourceService.GetResource(mapid);<br /> |
| 38 | <span style="color:#3399FF;">IMappingService</span> mapSvc = (<span style="color:#3399FF;">IMappingService</span>)con.GetService((<span style="color:#0000FF;">int</span>)<span style="color:#3399FF;">ServiceType</span>.Mapping);<br /> |
| 39 | <span style="color:#3399FF;">RuntimeMap</span> map = mapSvc.CreateMap(mapDef); |
| 40 | </td> |
| 41 | </tr> |
| 42 | <tr> |
| 43 | <td> |
| 44 | <span style="color:#3399FF;">IWebLayout</span> layout = con.GetWebLayout(webLayout);</td> |
| 45 | <td> |
| 46 | <span style="color:#3399FF;">IWebLayout</span> layout = (<span style="color:#3399FF;">IWebLayout</span>)con.ResourceService.GetResource(webLayout);</td> |
| 47 | </tr> |
| 48 | <tr> |
| 49 | <td> |
| 50 | <span style="color:#3399FF;">MapDefinition</span> layer = con.GetMapDefinition(mapDefId); |
| 51 | </td> |
| 52 | <td> |
| 53 | <span style="color:#3399FF;">IMapDefinition</span> layout = (<span style="color:#3399FF;">IMapDefinition</span>)con.ResourceService.GetResource(mapDefId);</td> |
| 54 | </tr> |
| 55 | <tr> |
| 56 | <td> |
| 57 | MapDefinition.BaseMapDefinition</td> |
| 58 | <td> |
| 59 | IMapDefinition.</td> |
| 60 | </tr> |
| 61 | <tr> |
| 62 | <td> |
| 63 | <span style="color:#0000FF;">for</span> (<span style="color:#0000FF;">int</span> i = 0; i < mdef.BaseMap.FiniteDisplayScale.Count; i++)</td> |
| 64 | <td> |
| 65 | <span style="color:#0000FF;">foreach</span> (<span style="color:#0000FF;">double</span> d <span style="color:#0000FF;">in</span> baseMap.FiniteDisplayScale)</td> |
| 66 | </tr> |
| 67 | <tr> |
| 68 | <td> |
| 69 | RuntimeMapLayer.Geometry</td> |
| 70 | <td> |
| 71 | RuntimeMapLayer.GeometryPropertyName</td> |
| 72 | </tr> |
| 73 | <tr> |
| 74 | <td> |
| 75 | RuntimeMapLayer.Guid</td> |
| 76 | <td> |
| 77 | RuntimeMapLayer.LayerDefinitionID</td> |
| 78 | </tr> |
| 79 | <tr> |
| 80 | <td> |
| 81 | <span style="color:#3399FF;">LayerDefinition</span> ldef = con.GetLayerDefinition(rl.ResourceId);</td> |
| 82 | <td> |
| 83 | <span style="color:#3399FF;">ILayerDefinition</span> ldef = (<span style="color:#3399FF;">ILayerDefinition</span>)con.ResourceService.GetResource(rl.LayerDefinitionID);</td> |
| 84 | </tr> |
| 85 | <tr> |
| 86 | <td> |
| 87 | FeatureSource fs = con.GetFeatureSource(vldef.ResourceId);</td> |
| 88 | <td> |
| 89 | <span style="color:#3399FF;">IFeatureSource</span> fs = <span style="color:#3399FF;">ObjectFactory</span>.CreateFeatureSource(con, vldef.ResourceId);</td> |
| 90 | </tr> |
| 91 | <tr> |
| 92 | <td> |
| 93 | RuntimeMap.LayerGroups</td> |
| 94 | <td> |
| 95 | RuntimeMap.Groups</td> |
| 96 | </tr> |
| 97 | <tr> |
| 98 | <td> |
| 99 | map.Layers.RemoveAt(0);</td> |
| 100 | <td> |
| 101 | Add:<br /> |
| 102 | using System.Linq; |
| 103 | To make this work. |
| 104 | </td> |
| 105 | </tr> |
| 106 | <tr> |
| 107 | <td> |
| 108 | con.SaveResourceAs(mdef, rtmDef);</td> |
| 109 | <td> |
| 110 | con.ResourceService.SaveResourceAs(mdef, rtmDef);</td> |
| 111 | </tr> |
| 112 | <tr> |
| 113 | <td> |
| 114 | ldef.Item as VectorLayerDefinitionType</td> |
| 115 | <td> |
| 116 | ldef.SubLayer;</td> |
| 117 | </tr> |
| 118 | <tr> |
| 119 | <td> |
| 120 | FeatureSetReader rd = layer.Query(filter, new string[] { layer.Geometry }) |
| 121 | </td> |
| 122 | <td> |
| 123 | <span style="color:#3399FF;">IReader</span> rd = |
| 124 | map.CurrentConnection.FeatureService.QueryFeatureSource(layer.FeatureSourceID, |
| 125 | layer.QualifiedClassName, <span style="color:#0000FF;">new string</span>[] { layer.GeometryPropertyName })</td> |
| 126 | </tr> |
| 127 | <tr> |
| 128 | <td> |
| 129 | VectorScaleRangeType.Items</td> |
| 130 | <td> |
| 131 | <span style="color:#3399FF;">IVectorScaleRange</span>.PointStyle<br /> |
| 132 | <span style="color:#3399FF;">IVectorScaleRange</span>.LineStyle<br /> |
| 133 | <span style="color:#3399FF;">IVectorScaleRange</span>.AreaStyle</td> |
| 134 | </tr> |
| 135 | <tr> |
| 136 | <td> |
| 137 | VectorScaleRange.MinScaleSpecified/MaxScaleSpecified</td> |
| 138 | <td> |
| 139 | <span style="color:#3399FF;">IVectorScaleRange.MinScale.HasValue/.MaxScale.HasValue</td> |
| 140 | </tr> |
| 141 | <tr> |
| 142 | <td> |
| 143 | PointTypeStyleType</td> |
| 144 | <td> |
| 145 | <span style="color:#3399FF;">IPointVectorStyle</span></td> |
| 146 | </tr> |
| 147 | <tr> |
| 148 | <td> |
| 149 | LineTypeStyleType</td> |
| 150 | <td> |
| 151 | <span style="color:#3399FF;">ILineVectorStyle</span></td> |
| 152 | </tr> |
| 153 | <tr> |
| 154 | <td> |
| 155 | AreaTypeStyleType</td> |
| 156 | <td> |
| 157 | <span style="color:#3399FF;">IAreaVectorStyle</span></td> |
| 158 | </tr> |
| 159 | <tr> |
| 160 | <td> |
| 161 | LineRuleType</td> |
| 162 | <td> |
| 163 | <span style="color:#3399FF;">ILineRule</span></td> |
| 164 | </tr> |
| 165 | <tr> |
| 166 | <td> |
| 167 | PointRuleType.Item</td> |
| 168 | <td> |
| 169 | <span style="color:#3399FF;">IPointRule</span>.PointSymbolization2D</td> |
| 170 | </tr> |
| 171 | <tr> |
| 172 | <td> |
| 173 | LineRuleType.Item</td> |
| 174 | <td> |
| 175 | <span style="color:#3399FF;">ILineRule</span>.Stroke</td> |
| 176 | </tr> |
| 177 | <tr> |
| 178 | <td> |
| 179 | AreaRuleType.Item</td> |
| 180 | <td> |
| 181 | <span style="color:#3399FF;">IAreaRule</span>.AreaSymbolization2D</td> |
| 182 | </tr> |
| 183 | <tr> |
| 184 | <td> |
| 185 | AreaTypeStyleType.AreaRule</td> |
| 186 | <td> |
| 187 | <span style="color:#3399FF;">IAreaVectorStyle.Rules</span></td> |
| 188 | </tr> |
| 189 | <tr> |
| 190 | <td> |
| 191 | GridLayerDefinitionType</td> |
| 192 | <td> |
| 193 | <span style="color:#3399FF;">IRasterLayerDefinition</span></td> |
| 194 | </tr> |
| 195 | <tr> |
| 196 | <td> |
| 197 | LayerDefinition.Item</td> |
| 198 | <td> |
| 199 | <span style="color:#3399FF;">ILayerDefinition</span></td> |
| 200 | </tr> |
| 201 | <tr> |
| 202 | <td> |
| 203 | LineTypeStyle.Items |
| 204 | </td> |
| 205 | <td> |
| 206 | <span style="color:#3399FF;">ILineRule</span>.Strokes |
| 207 | </td> |
| 208 | </tr> |
| 209 | <tr> |
| 210 | <td> |
| 211 | ServerConnectionI.GetLegendImage</td> |
| 212 | <td> |
| 213 | <span style="color:#3399FF;">IMappingServicea</span>.RenderMapLegend</td> |
| 214 | </tr> |
| 215 | <tr> |
| 216 | <td> |
| 217 | ServerConnectionI.DescribeFeatureSource</td> |
| 218 | <td> |
| 219 | <span style="color:#3399FF;">IServerConnection</span>.FeatureService.DescribeFeatureSource</td> |
| 220 | </tr> |
| 221 | <tr> |
| 222 | <td> |
| 223 | FeatureSourceReader.Read()</td> |
| 224 | <td> |
| 225 | IReader.ReadNext()</td> |
| 226 | </tr> |
| 227 | <tr> |
| 228 | <td> |
| 229 | FeatureSourceReader.Row.IsValueNull(column)</td> |
| 230 | <td> |
| 231 | IReader.IsNull(column)</td> |
| 232 | </tr> |
| 233 | <tr> |
| 234 | <td> |
| 235 | foreach (FeatureSetColumn fsc in fsr.Columns)</td> |
| 236 | <td> |
| 237 | for (int i=0; i<fsr.FieldCount; i++)</td> |
| 238 | </tr> |
| 239 | <tr> |
| 240 | <td> |
| 241 | FeatureSetReader.Columns.Length</td> |
| 242 | <td> |
| 243 | IReader.FieldCount</td> |
| 244 | </tr> |
| 245 | <tr> |
| 246 | <td> |
| 247 | FeatureSetReader.Columns[i].Type</td> |
| 248 | <td> |
| 249 | IReader.GetFieldType(i)</td> |
| 250 | </tr> |
| 251 | <tr> |
| 252 | <td> |
| 253 | FeatureSourceDescription.FeatureSourceSchema</td> |
| 254 | <td> |
| 255 | FeatureSchema</td> |
| 256 | </tr> |
| 257 | <tr> |
| 258 | <td> |
| 259 | RuntimeMapLayer.NeedRefresh</td> |
| 260 | <td> |
| 261 | RuntimeMapLayer.NeedsRefresh (to get) RuntimeMapLayer.ForceRefresh() (to set)</td> |
| 262 | </tr> |
| 263 | <tr> |
| 264 | <td> |
| 265 | RuntimeMapLayer.ResourceID</td> |
| 266 | <td> |
| 267 | RuntimeMapLayer.LayerDefinitionID</td> |
| 268 | </tr> |
| 269 | <tr> |
| 270 | <td> |
| 271 | RuntimeMap.Extents</td> |
| 272 | <td> |
| 273 | RuntimeMap.DataExtent</td> |
| 274 | </tr> |
| 275 | <tr> |
| 276 | <td> |
| 277 | ServerConnectionI.HasFolder</td> |
| 278 | <td> |
| 279 | con.ResourceService.ResourceExists(folderpath)<br /> |
| 280 | Make sure that folderpath ends with '/' to indicate it's a folder |
| 281 | </td> |
| 282 | </tr> |
| 283 | <tr> |
| 284 | <td> |
| 285 | ServerConnectionI.CreateFolder</td> |
| 286 | <td> |
| 287 | con.ResourceService.SetResourceXmlData(folderpath, null)</td> |
| 288 | </tr> |
| 289 | <tr> |
| 290 | <td> |
| 291 | RuntimeMapLayer.ResourceId</td> |
| 292 | <td> |
| 293 | RuntimeMapLayer.LayerDefinitionID</td> |
| 294 | </tr> |
| 295 | <tr> |
| 296 | <td> |
| 297 | map.FiniteScales</td> |
| 298 | <td> |
| 299 | IMapDefinition mdef = |
| 300 | (IMapDefinition)map.CurrentConnection.ResourceService.GetResource(map.MapDefinition);<br /> |
| 301 | IBaseMapDefinition bm = mdef.BaseMap;<br /> |
| 302 | bm.FiniteDisplayScale.ToArray();</td> |
| 303 | </tr> |
| 304 | </table> |
| 305 | }}} |