阅读:2127回复:1
我再 EDN上发现的代码根据 style文件得到symbol的代码
import java.io.*;<BR><BR>import com.esri.arcgis.display.*;<BR>import com.esri.arcgis.server.*;<BR>import com.esri.arcgis.system.*;<BR><BR>public class GetSymbolFromServerStyleGallery {<BR><BR> private static AoInitialize aoInit;<BR> private IServerContext sc;<BR> public GetSymbolFromServerStyleGallery() {}<BR><BR> private void connectToServer() {<BR><BR> String host = "husker";<BR> String domain = "gisdomain";<BR> String user = "user1";<BR> String password = "password";<BR><BR> try {<BR> <BR> // Initialize ArcObjects for Server usage<BR> new ServerInitializer().initializeServer(domain,<BR> user, password);<BR> <BR> // Connect to the host machine where the ArcGIS Server Object Manager is running<BR> ServerConnection connection = new ServerConnection();<BR> connection.connect(host);<BR><BR> // Get the SOM and create an empty context.<BR> IServerObjectManager som = connection.getServerObjectManager();<BR> sc = som.createServerContext("", "");<BR><BR> } catch (Exception ex) {<BR> ex.printStackTrace();<BR> }<BR> }<BR><BR> public void listMarkerSymbols() {<BR><BR> try {<BR><BR> // Create the object on the server, within the empty context.<BR> ServerStyleGallery ssg = new ServerStyleGallery(sc.createObject(ServerStyleGallery.getClsid()));<BR><BR> //You need to add the style file, by name, to the ServerStyleGallery<BR> String path = "C:\\ArcGIS\\Styles\\Caves.ServerStyle";<BR> ssg.addFile(path);<BR><BR> //Get the list of all Marker Symbols from the Default category of the gallery<BR> EnumServerStyleGalleryItem items =<BR> new EnumServerStyleGalleryItem(ssg.getItems(<BR> "Marker Symbols", path, "Default"));<BR><BR> //Iterate through the collection and print out the name and the size of each symbol<BR> IStyleGalleryItem item = items.next();<BR><BR> while (item != null) {<BR><BR> IMarkerSymbol sms = new IMarkerSymbolProxy(item.getItem());<BR> System.out.println("Symbol Name: " + item.getName());<BR> System.out.println("Symbol Size: " + sms.getSize());<BR> System.out.println("");<BR> item = items.next();<BR> }<BR><BR> //Once we are done using the objects in the server context, remove them and release the context<BR> sc.removeAll();<BR> sc.releaseContext();<BR><BR> } catch (IOException ex) {<BR> ex.printStackTrace();<BR> }<BR> }<BR><BR> public static void main(String[] args) {<BR><BR> GetSymbolFromServerStyleGallery getsymbolfromserverstylegallery = new<BR> GetSymbolFromServerStyleGallery();<BR><BR> getsymbolfromserverstylegallery.connectToServer();<BR> getsymbolfromserverstylegallery.listMarkerSymbols();<BR><BR> }<BR>}<BR>
|
|
1楼#
发布于:2005-09-05 21:31
多谢!受益匪浅啊!<img src="images/post/smile/dvbbs/em02.gif" />
|
|