Re: [mapguide-users] MSSql and mapguide, data not displayed
If you are invoking SelectFeatures() from MgLayer you need to instantiate MgMap with an MgSiteConnection object otherwise you'll get an Exception - Jackie deakaron wrote: > > Thanks for your answer. > > Now I have another problem, I have the following code that throws an > exception whenever I try to read features from any layer of the Sheboygan > map. > > import org.osgeo.mapguide.MapGuideJavaApi; > import org.osgeo.mapguide.MgException; > import org.osgeo.mapguide.MgFeatureQueryOptions; > import org.osgeo.mapguide.MgFeatureService; > import org.osgeo.mapguide.MgLayerBase; > import org.osgeo.mapguide.MgMap; > import org.osgeo.mapguide.MgRenderingService; > import org.osgeo.mapguide.MgResourceIdentifier; > import org.osgeo.mapguide.MgResourceService; > import org.osgeo.mapguide.MgServiceType; > import org.osgeo.mapguide.MgSite; > import org.osgeo.mapguide.MgSiteConnection; > import org.osgeo.mapguide.MgUserInformation; > > public class Program { > > /** >* @param args >*/ > public static void main(String[] args) { > try { > MgResourceIdentifier mapDefid = new > MgResourceIdentifier( > > "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition"); > try { > > MapGuideJavaApi.MgInitializeWebTier("C:\\webconfig.ini"); > } catch (Exception ex) { > ex.printStackTrace(); > } > MgUserInformation userInfo = new > MgUserInformation("Anonymous", ""); > MgSite site = new MgSite(); > site.Open(userInfo); > String sessionId = site.CreateSession(); > site.Close(); > > MgSiteConnection siteConnection = new > MgSiteConnection(); > siteConnection.Open(new MgUserInformation(sessionId)); > MgResourceService service = (MgResourceService) > siteConnection > > .CreateService(MgServiceType.ResourceService); > MgResourceService resourceService = > (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService); > MgMap map = new MgMap(); > map.Open(resourceService, "Sheboygan"); > MgRenderingService renderingService = > (MgRenderingService) > siteConnection > > .CreateService(MgServiceType.RenderingService); > MgFeatureService featureService = (MgFeatureService) > siteConnection > > .CreateService(MgServiceType.FeatureService); > /** >* Make all layers visible >*/ > for (int i = 0; i < map.GetLayers().GetCount(); i++) { > MgFeatureQueryOptions queryOptions = new > MgFeatureQueryOptions(); > queryOptions.SetFilter("Autogenerated_SDF_ID = > 1"); > MgLayerBase layer = map.GetLayers().GetItem(i); > layer.SetVisible(true); > try { > layer.SelectFeatures(queryOptions); > } catch (Exception ex) { > ex.printStackTrace(); > } > System.out.println("Layer name: " + > layer.GetName()); > } > } catch (MgException ex) { > ex.printStackTrace(); > } > } > > } > -- View this message in context: http://www.nabble.com/MSSql-and-mapguide%2C-data-not-displayed-tp15760131s16610p15809764.html Sent from the MapGuide Users mailing list archive at Nabble.com. ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users
Re: [mapguide-users] MSSql and mapguide, data not displayed
Did you define a spatial context (a coordinate system) for that ODBC feature source? If so, is it the same one as the Sheboygan map? - Jackie deakaron wrote: > > I am trying to display features in mapguide using a resource that should > read data from an MSSql table. > > the table SpatialData(Id int, Name nvarchar(50), x float, y float) > > http://www.nabble.com/file/p15760131/mssql.jpg > > The table already contains two rows with coordinates that are inside the > sample Sheboygan map, I use an OBDC connection, the Studio recignizes the > geometric and other data fine as can be seen on the image, but if i try to > preview nothing can be seen or selected no matter what scale settings I > use. > > Here are my settings: > > http://www.nabble.com/file/p15760131/mapguide.jpg > > any help would be appreciated > > -- View this message in context: http://www.nabble.com/MSSql-and-mapguide%2C-data-not-displayed-tp15760131s16610p15798008.html Sent from the MapGuide Users mailing list archive at Nabble.com. ___ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users