精华内容
下载资源
问答
  • 但如果iServer已有的服务不能满足要求,想自行基于iObjects Java进行开发时,默认情况下要么开发出来的是个CS版的GIS应用系统,要么是个独立的BS站点,还不能与iServer使用同一个Tomcat部署(会导致许可验证出现问题)...

           在使用SuperMap iServer时,自带的服务可以满足日常对于地理信息的大部分需求,如地图浏览、数据查询、空间分析等。但如果iServer已有的服务不能满足要求,想自行基于iObjects Java进行开发时,默认情况下要么开发出来的是个CS版的GIS应用系统,要么是个独立的BS站点,还不能与iServer使用同一个Tomcat部署(会导致许可验证出现问题)。所以,能否将自己开发的BS应用增加到iServer里,就像使用iServer一样方便地调用自己开发的GIS服务哪?

           幸好,iServer天生就是支持可扩展的,也就是可以将自己开发的GIS服务注册到iServer中,这样使用起来就会方便许多。下面,我来介绍一下以面对象的融合运算为例如何进行iServer扩展开发。

           首先,需要在eclipse等IDE里开发GIS服务。在eclipse里新建一个Java Project工程,名字为“GeometryCaculate”,JDK或JRE版本选择1.7及以上版本,如下图所示:


           第二步,为工程配置iObjects Java依赖库。在工程的properties/Java Build Path/Libraries对话框中单击“Add Library...”按钮,打开如下对话框:


           在弹出的对话框中单击右侧的“User Libraries...”按钮,再在弹出的对话框中单击右侧的“New...”按钮,然后输入用户库的名称,如“ObjectsJava9”,然后单击右侧的“Add External JARs...”按钮,在弹出的选件选择对话框中选中iObjectsJava的bin目录下的所有jar包:


           添加完毕后效果如下图所示:


           依次单击“OK”及“Finish”按钮完成对iObjects Java的引用配置。再单击“OK”按钮完成对iObjects Java组件的引用:


           新建package及class:


           在RegionUnionAnalysis中编写如下代码:

    package com.iserver.ext;
    
    import com.supermap.data.CursorType;
    import com.supermap.data.Dataset;
    import com.supermap.data.DatasetVector;
    import com.supermap.data.Datasource;
    import com.supermap.data.DatasourceConnectionInfo;
    import com.supermap.data.EngineType;
    import com.supermap.data.GeoRegion;
    import com.supermap.data.Geometrist;
    import com.supermap.data.Geometry;
    import com.supermap.data.Point2D;
    import com.supermap.data.Point2Ds;
    import com.supermap.data.PrjCoordSys;
    import com.supermap.data.Recordset;
    import com.supermap.data.Workspace;
    
    public class RegionUnionAnalysis {
    	public static void main(String[] args){
    		System.out.println(union());
    	}
    	
    	public static String union(){
    		String[] arrRegionsCoords = {"120.35692147550832,36.05514432464903;120.35689117466774,36.05511519855853;120.35686167450855,36.055085261780235;120.35683299671253,36.05505453631681;120.35680516235703,36.05502304475061;120.35677819189954,36.054990810227046;120.35675210516256,36.05495785643757;120.3567269213191,36.054924207602284;120.35670265887858,36.05488988845213;120.3566793356732,36.05485492421071;120.35665696884487,36.05481934057574;120.35663557483255,36.0547831637002;120.35661516936025,36.054746420173046;120.3565957674254,36.05470913699975;120.35657738328788,36.05467134158237;120.35656003045952,36.05463306169947;120.35654372169412,36.05459432548568;120.35652846897821,36.05455516141102;120.35651428352206,36.05451559825996;120.3565011757516,36.05447566511031;120.35648915530066,36.0544353913118;120.35647823100395,36.05439480646452;120.3564684108905,36.05435394039719;120.35645970217782,36.05431282314521;120.35645211126655,36.05427148492859;120.35644564373582,36.054229956129745;120.35644030433907,36.05418826727117;120.35643609700061,36.05414644899299;120.3564330248127,36.05410453203044;120.35643109003333,36.05406254719132;120.35643029408449,36.054020525333286;120.3564306375512,36.05397849734121;120.35643212018101,36.05393649410448;120.35643474088423,36.05389454649428;120.35643849773471,36.0538526853409;120.35644338797128,36.05381094141112;120.35644940799976,36.05376934538554;120.3564565533956,36.05372792783605;120.35646481890711,36.053686719203384;120.35647419845942,36.05364574977471;120.35648468515878,36.05360504966139;120.35649627129779,36.05356464877687;120.35650894836095,36.053524576814645;120.356522707031,36.05348486322647;120.35653753719569,36.05344553720071;120.35655342795529,36.05340662764087;120.35657036763051,36.05336816314437;120.3565883437712,36.053330171981536;120.35660734316538,36.05329268207479;120.35662735184904,36.05325572097815;120.35664835511639,36.05321931585697;120.3566703375306,36.05318349346799;120.35669328293524,36.05314828013964;120.35671717446606,36.053113701752714;120.35674199456348,36.05307978372136;120.35676772498543,36.05304655097436;120.35679434682079,36.05301402793683;120.35682184050324,36.0529822385123;120.35685018582573,36.05295120606509;120.35687936195525,36.05292095340316;120.35690934744817,36.05289150276136;120.35694012026597,36.05286287578508;120.35697165779155,36.05283509351433;120.3570039368457,36.0528081763683;120.35703693370424,36.052782144130326;120.3570706241154,36.05275701593336;120.3571049833177,36.052732810245914;120.35713998605809,36.05270954485848;120.35717560661055,36.05268723687046;120.357211818795,36.0526659026776;120.35724859599648,36.05264555795992;120.35728591118483,36.0526262176702;120.35732373693442,36.05260789602303;120.357980579149,36.0540121793781;120.35692147550832,36.05514432464903",
    								  "120.357131210369,36.0536361947787;120.35711749076883,36.05361052624525;120.35710432351318,36.053584570043355;120.35709171463057,36.05355833805682;120.35707966989388,36.05353184229572;120.35706819481767,36.05350509489091;120.3570572946557,36.05347810808844;120.35704697439851,36.05345089424399;120.35703723877116,36.05342346581716;120.35702809223099,36.053395835365826;120.35701953896567,36.05336801554032;120.35701158289125,36.05334001907773;120.35700422765034,36.05331185879596;120.35699747661045,36.05328354758795;120.35699133286252,36.05325509841574;120.35698579921939,36.05322652430452;120.35698087821457,36.05319783833669;120.35697657210115,36.05316905364588;120.35697288285058,36.05314018341089;120.35696981215202,36.05311124084969;120.35696736141131,36.05308223921339;120.3569655317505,36.053053191780116;120.35696432400732,36.053024111848984;120.3569637387347,36.05299501273398;120.35696377620062,36.052965907757866;120.35696443638788,36.052936810246095;120.35696571899427,36.05290773352071;120.35696762343255,36.052878690894225;120.35697014883078,36.05284969566355;120.35697329403273,36.05282076110388;120.35697705759839,36.052791900462665;120.35698143780465,36.052763126953465;120.35698643264608,36.05273445375;120.35699203983584,36.05270589398002;120.35699825680672,36.052677460719366;120.35700508071233,36.05264916698595;120.35701250842841,36.05262102573381;120.35702053655424,36.05259304984716;120.35702916141425,36.052565252134514;120.35703837905957,36.05253764532281;120.35704818527003,36.05251024205156;120.35705857555593,36.05248305486713;120.35706954516014,36.052456096216915;120.35708108906037,36.0524293784437;120.35709320197134,36.052402913779964;120.35710587834724,36.05237671434233;120.35711911238431,36.05235079212598;120.3571328980235,36.052325158999146;120.35714722895312,36.05229982669775;120.35716209861192,36.052274806819945;120.35717750019197,36.052250110820864;120.35719342664176,36.052225750007345;120.35720987066952,36.052201735532776;120.35722682474652,36.05217807839196;120.35724428111045,36.05215478941611;120.35726223176911,36.052131879267876;120.35728066850393,36.05210935843646;120.35729958287382,36.05208723723283;120.35731896621901,36.05206552578498;120.357338809665,36.0520442340333;120.35735910412664,36.05202337172603;120.3573798403123,36.05200294841478;120.35740100872812,36.0519829734502;120.35742259968231,36.05196345597763;120.35744460328965,36.051944404932975;120.35746700947598,36.05192582903859;120.35748980798284,36.05190773679928;120.35751298837214,36.051890136498415;120.35753654003092,36.05187303619413;120.35756045217629,36.05185644371565;120.35758471386028,36.0518403666597;120.35760931397489,36.051824812387004;120.3576342412572,36.05180978801895;120.358323901903,36.0529822111164;120.357131210369,36.0536361947787",
    								  "120.35756501276337,36.05253197133556;120.35755785617123,36.05250811877166;120.35755134042094,36.0524840832435;120.35754547017903,36.05245988196511;120.3575402496497,36.052435532269236;120.35753568257185,36.0524110515949;120.35753177221639,36.05238645747496;120.35752852138388,36.052361767523486;120.35752593240254,36.05233699942321;120.35752400712654,36.05231217091282;120.3575227469348,36.05228729977428;120.35752215272981,36.052262403820066;120.35752222493718,36.052237500880445;120.35752296350516,36.052212608790676;120.3575243679048,36.05218774537825;120.35752643713029,36.05216292845012;120.35752916969967,36.05213817577996;120.3575325636559,36.05211350509539;120.35753661656824,36.05208893406535;120.35754132553406,36.05206448028739;120.35754668718081,36.05204016127508;120.35755269766855,36.052015994445476;120.35755935269262,36.05199199710666;120.35756664748673,36.05196818644529;120.35757457682644,36.05194457951438;120.35758313503281,36.05192119322096;120.35759231597655,36.05189804431412;120.35760211308232,36.05187514937289;120.35761251933354,36.05185252479441;120.35762352727735,36.05183018678222;120.35763512902996,36.05180815133459;120.35764731628228,36.05178643423311;120.35766008030592,36.05176505103138;120.3576734119594,36.05174401704386;120.35768730169471,36.05172334733489;120.35770173956415,36.05170305670794;120.35771671522744,36.05168315969499;120.35773221795915,36.05166367054607;120.35774823665635,36.05164460321916;120.35776475984662,36.0516259713701;120.35778177569615,36.05160778834285;120.3577992720184,36.05159006715994;120.35781723628263,36.051572820513115;120.35783565562298,36.05155606075427;120.35785451684771,36.051539799886605;120.35787380644857,36.05152404955599;120.35789351061052,36.05150882104268;120.35791361522162,36.0514941252532;120.35793410588312,36.05147997271255;120.3579549679198,36.051466373556636;120.35797618639045,36.05145333752507;120.35799774609858,36.05144087395412;120.35801963160334,36.0514289917701;120.35804182723052,36.051417699482926;120.35806431708382,36.051407005180025;120.3580870850562,36.05139691652056;120.35811011484142,36.05138744072995;120.35813338994579,36.05137858459465;120.35815689369987,36.05137035445736;120.35818060927049,36.051362756212434;120.35820451967277,36.05135579530166;120.35822860778228,36.051349476710385;120.35825285634735,36.05134380496392;120.35827724800136,36.05133878412432;120.35830176527524,36.05133441778747;120.35832639060992,36.0513307090805;120.35835110636897,36.05132766065955;120.35837589485118,36.05132527470788;120.35840073830327,36.05132355293428;120.35842561893257,36.05132249657187;120.3584505189198,36.05132210637721;120.3584754204318,36.05132238262974;120.35850030563435,36.051323325131634;120.358452647935,36.0522526502644;120.35756501276337,36.05253197133556",
    								  "120.35805972781905,36.0520909789408;120.3580589318769,36.05206966921132;120.35805867418641,36.052048346179404;120.35805895491188,36.05202702343832;120.35805977387433,36.05200571458113;120.35806113055169,36.051984433192054;120.35806302407909,36.05196319283781;120.35806545324941,36.051942007058955;120.3580684165141,36.05192088936124;120.35807191198407,36.05189985320703;120.35807593743101,36.0518789120067;120.35808049028871,36.0518580791101;120.3580855676548,36.051837367798015;120.35809116629245,36.05181679127375;120.3580972826326,36.05179636265468;120.35810391277614,36.05177609496386;120.3581110524964,36.051756001121795;120.35811869724185,36.05173609393813;120.35812684213906,36.05171638610356;120.35813548199569,36.05169689018163;120.35814461130393,36.05167761860086;120.3581542242439,36.05165858364672;120.35816431468746,36.051639797453824;120.358174876202,36.051621271998236;120.35818590205464,36.05160301908977;120.35819738521653,36.0515850503645;120.3582093183672,36.05156737727736;120.3582216938994,36.05155001109478;120.35823450392381,36.05153296288758;120.35824774027415,36.051516243523835;120.35826139451235,36.05149986366201;120.35827545793396,36.05148383374413;120.35828992157364,36.05146816398914;120.35830477621094,36.051452864386384;120.35832001237618,36.051437944689226;120.3583356203564,36.05142341440885;120.35835159020166,36.0514092828082;120.35836791173129,36.051395558896054;120.35838457454047,36.05138225142129;120.35840156800678,36.05136936886731;120.35841888129704,36.05135691944665;120.35843650337415,36.051344911095704;120.3584544230042,36.051333351469694;120.35847262876355,36.051322247937804;120.3584911090462,36.05131160757843;120.35850985207111,36.051301437174715;120.35852884588975,36.051291743210214;120.35854807839372,36.05128253186474;120.35856753732246,36.051273809010475;120.35858721027105,36.05126558020814;120.35860708469816,36.051257850703536;120.358627147934,36.05125062542417;120.35864738718843,36.05124390897609;120.35866778955906,36.05123770564098;120.35868834203958,36.05123201937341;120.35870903152794,36.05122685379833;120.35872984483476,36.05122221220876;120.3587507686917,36.05121809756367;120.35877178976003,36.05121451248611;120.35879289463894,36.051211459261545;120.35881406987427,36.05120893983637;120.35883530196696,36.0512069558167;120.35885657738174,36.05120550846735;120.35887788255572,36.05120459871097;120.35889920390699,36.05120422712753;120.35892052784338,36.05120439395392;120.35894184077105,36.051205099083774;120.3589631291032,36.05120634206759;120.35898437926868,36.05120812211297;120.35900557772068,36.05121043808514;120.35902671094536,36.05121328850771;120.35904776547046,36.051216671563544;120.35906872787392,36.051220585095976;120.35890325905,36.0520488023792;120.35805972781905,36.0520909789408",
    								  "120.35961179777796,36.053849053518555;120.35960348495885,36.05383722399362;120.35959552492928,36.053825154256636;120.35958792462576,36.05381285482542;120.35958069067135,36.05380033641796;120.35957382936988,36.053787609943036;120.35956734670043,36.05377468649077;120.35956124831212,36.053761577322916;120.3595555395192,36.05374829386307;120.35955022529646,36.05373484768673;120.35954531027481,36.053721250511146;120.35954079873729,36.053707514185184;120.35953669461534,36.05369365067896;120.3595330014854,36.05367967207341;120.35952972256574,36.05366559054979;120.35952686071364,36.05365141837902;120.35952441842302,36.05363716791101;120.35952239782212,36.05362285156394;120.35952080067173,36.05360848181333;120.35951962836364,36.0535940711813;120.35951888191944,36.05357963222556;120.35951856198959,36.05356517752852;120.35951866885287,36.053550719686285;120.35951920241617,36.05353627129772;120.35952016221452,36.05352184495346;120.35952154741156,36.0535074532249;120.35952335680017,36.05349310865329;120.35952558880362,36.05347882373879;120.35952824147691,36.05346461092956;120.35953131250842,36.053450482610934;120.35953479922202,36.05343645109462;120.3595386985793,36.05342252860797;120.35954300718228,36.05340872728332;120.35954772127636,36.05339505914743;120.35955283675358,36.05338153611098;120.3595583491562,36.05336816995825;120.35956425368062,36.05335497233675;120.3595705451815,36.053341954747175;120.35957721817631,36.053329128533306;120.35958426685005,36.05331650487218;120.35959168506037,36.05330409476431;120.35959946634289,36.05329190902411;120.35960760391684,36.0532799582705;120.35961609069098,36.0532682529176;120.35962491926973,36.05325680316569;120.35963408195973,36.05324561899232;120.3596435707764,36.05323471014362;120.35965337745098,36.05322408612577;120.35966349343776,36.05321375619676;120.35967390992145,36.05320372935831;120.35968461782491,36.053194014348;120.35969560781706,36.0531846196317;120.35970687032098,36.05317555339615;120.35971839552231,36.05316682354186;120.35973017337776,36.05315843767619;120.35974219362384,36.05315040310677;120.35975444578588,36.053142726835084;120.3597669191871,36.053135415550386;120.35977960295791,36.053128475623886;120.35979248604542,36.053121913103176;120.35980555722303,36.053115733706974;120.35981880510028,36.05310994282013;120.35983221813265,36.053104545488935;120.3598457846318,36.05309954641674;120.35985949277557,36.053094949959835;120.35987333061841,36.05309076012368;120.35988728610177,36.053086980559364;120.35990134706451,36.05308361456049;120.35991550125364,36.05308066506026;120.35992973633492,36.05307813462891;120.3599440399036,36.05307602547154;120.35995839949526,36.05307433942608;120.35997280259664,36.05307307796181;120.360008329164,36.0535615682636;120.35961179777796,36.053849053518555",
    								  "120.35978344079324,36.05316421707512;120.35979072709752,36.05315392707324;120.3597982956089,36.05314384282788;120.35980614052026,36.05313397207641;120.35981425581244,36.05312432239237;120.35982263525878,36.05311490117971;120.35983127242997,36.05310571566705;120.35984016069895,36.05309677290219;120.359849293246,36.05308807974665;120.35985866306399,36.05307964287046;120.35986826296369,36.05307146874698;120.3598780855794,36.053063563647996;120.35988812337446,36.05305593363888;120.35989836864718,36.05304858457391;120.35990881353663,36.053041522091824;120.35991945002876,36.05303475161147;120.35993026996246,36.053028278327645;120.35994126503593,36.05302210720712;120.35995242681292,36.053016242984825;120.35996374672935,36.05301069016021;120.35997521609973,36.0530054529938;120.35998682612396,36.053000535503934;120.35999856789395,36.052995941463664;120.36001043240063,36.052991674397866;120.36002241054064,36.05298773758054;120.36003449312352,36.052984134032286;120.36004667087863,36.05298086651803;120.36005893446232,36.052977937544824;120.36007127446508,36.05297534935999;120.36008368141879,36.05297310394938;120.36009614580392,36.052971203035824;120.3601086580569,36.05296964807785;120.36012120857743,36.05296844026853;120.36013378773585,36.05296758053458;120.36014638588051,36.05296706953564;120.36015899334522,36.0529669076638;120.36017160045662,36.052967095043265;120.36018419754163,36.052967631530244;120.36019677493485,36.05296851671312;120.36020932298601,36.05296974991271;120.36022183206732,36.05297133018283;120.36023429258093,36.052973256310956;120.36024669496624,36.052975526819246;120.36025902970721,36.05297813996559;120.36027128733978,36.052981093745;120.360283458459,36.052984385891115;120.36029553372629,36.05298801387798;120.36030750387665,36.05299197492192;120.36031935972574,36.052996265983765;120.36033109217685,36.05300088377108;120.36034269222804,36.053005824740765;120.36035415097889,36.053011085101765;120.36036545963744,36.053016660817946;120.36037660952685,36.05302254761122;120.36038759209214,36.053028740964805;120.36039839890668,36.05303523612673;120.3604090216787,36.053042028113424;120.36041945225769,36.05304911171359;120.36042968264049,36.053056481492185;120.36043970497765,36.05306413179458;120.36044951157932,36.053072056750906;120.36045909492114,36.05308025028057;120.3604684476501,36.053088706096915;120.36047756259012,36.05309741771201;120.36048643274752,36.05310637844169;120.36049505131652,36.05311558141064;120.36050341168432,36.05312501955766;120.36051150743623,36.05313468564115;120.36051933236062,36.05314457224457;120.36052688045365,36.053154671782224;120.36053414592385,36.053164976505;120.36054112319665,36.0531754785064;120.36054780691859,36.0531861697285;120.36015853286929,36.05342209339488;120.35978344079324,36.05316421707512",
    								  "120.3603829220795,36.05300243532095;120.36039568517573,36.05300716682157;120.36040831296405,36.053012248424295;120.36042079584294,36.053017676265334;120.3604331243211,36.053023446217665;120.36044528902464,36.05302955389413;120.36045728070417,36.053035994650756;120.36046909024185,36.05304276359037;120.36048070865837,36.05304985556623;120.3604921271197,36.05305726518597;120.36050333694386,36.05306498681572;120.36051432960751,36.05307301458438;120.36052509675243,36.05308134238806;120.36053563019185,36.053089963894756;120.36054592191674,36.053098872549135;120.3605559641018,36.05310806157754;120.36056574911152,36.05311752399312;120.36057526950589,36.05312725260119;120.36058451804611,36.05313724000463;120.36059348770011,36.05314747860956;120.36060217164786,36.0531579606311;120.36061056328653,36.053168678099276;120.36061865623557,36.05317962286512;120.36062644434158,36.05319078660683;120.36063392168286,36.05320216083608;120.36064108257408,36.05321373690454;120.36064792157046,36.05322550601038;120.36065443347199,36.053237459205015;120.36066061332741,36.0532495873999;120.36066645643787,36.05326188137337;120.36067195836058,36.0532743317778;120.36067711491218,36.05328692914655;120.3606819221719,36.05329966390127;120.3606863764846,36.053312526359136;120.3606904744634,36.05332550674024;120.36069421299246,36.05333859517499;120.3606975892292,36.053351781711655;120.36070060060649,36.05336505632392;120.36070324483468,36.05337840891846;120.36070551990322,36.05339182934271;120.36070742408225,36.053405307392495;120.36070895592398,36.05341883281983;120.36071011426364,36.05343239534073;120.36071089822052,36.05344598464297;120.36071130719851,36.05345959039399;120.3607113408867,36.05347320224871;120.36071099925941,36.05348680985742;120.36071028257643,36.05350040287362;120.3607091913827,36.05351397096191;120.36070772650787,36.05352750380587;120.36070588906577,36.05354099111585;120.3607036804535,36.05355442263682;120.36070110235035,36.05356778815619;120.3606981567166,36.05358107751154;120.36069484579191,36.053594280598354;120.36069117209375,36.05360738737773;120.3606871384154,36.05362038788398;120.36068274782386,36.053633272232226;120.36067800365748,36.053646030625906;120.36067290952347,36.05365865336422;120.36066746929514,36.05367113084952;120.36066168710896,36.053683453594616;120.36065556736135,36.05369561222995;120.36064911470548,36.05370759751076;120.36064233404757,36.05371940032408;120.3606352305433,36.05373101169568;120.36062780959374,36.05374242279693;120.3606200768414,36.05375362495142;120.36061203816587,36.05376460964165;120.36060369967929,36.05377536851545;120.36059506772183,36.053785893392366;120.36058614885673,36.05379617626984;120.36057694986542,36.05380620932934;120.36021772941125,36.053467617925634;120.3603829220795,36.05300243532095"};
    		String strResult = "[";
    		
    		/*----------下列代码为测试代码,将计算结果写入udb数据集中,方便查看结果准确性--------*/
    		/*Workspace ws = new Workspace();
    		DatasourceConnectionInfo conninfo = new DatasourceConnectionInfo();
    		conninfo.setEngineType(EngineType.UDB);
    		conninfo.setServer("F:\\扇形面.udb");
    		Datasource datasource = ws.getDatasources().open(conninfo);
    		DatasetVector dsv = (DatasetVector)datasource.getDatasets().get("ResultRegion");
    		Recordset ds = dsv.getRecordset(false, CursorType.DYNAMIC);*/
    		
    		Geometry geoResult = null;
    		for(int i=0;i<arrRegionsCoords.length;i++){
    			String strRegionCoords = arrRegionsCoords[i];
    			String[] arrPointsCoords = strRegionCoords.split(";");
    			Point2Ds pts = new Point2Ds();
    			for(int j=0;j<arrPointsCoords.length;j++){
    				Point2D pt = new Point2D();
    				String[] arrCoords = arrPointsCoords[j].split(",");
    				pt.setX(Double.parseDouble(arrCoords[0]));
    				pt.setY(Double.parseDouble(arrCoords[1]));
    				pts.add(pt);
    			}
    			Geometry geoRegion = new GeoRegion(pts);
    			if(geoResult!=null){
    				geoResult = Geometrist.union(geoRegion, geoResult);		//每次都用之前的分析结果geoResult与新的面进行叠加分析,并把结果保存到geoResult中
    				
    			}else{
    				geoResult = geoRegion;
    			}
    		}
    		if(geoResult!=null){
    			Geometry[] arrGeoResult = ((GeoRegion)geoResult).protectedDecompose();	//由于经过union运算之后生成的geoResult是个组合对象,所以需要分解为多个单独的对象
    			//System.out.println(arrGeoResult.length);
    			/*-----------将union计算结果插入到数据集中-------*/
    			/*for(int i=0;i<arrGeoResult.length;i++){
    				ds.addNew(arrGeoResult[i]);
    				ds.update();
    			}*/
    			for(int i=0;i<arrGeoResult.length;i++){
    				GeoRegion geo = (GeoRegion)arrGeoResult[i];
    				Point2Ds points = geo.getPart(0);
    				strResult += "{\"points\":[";
    				for(int j=0;j<points.getCount();j++){
    					strResult += "{\"x\":" + points.getItem(j).getX() + ",\"y\":" + points.getItem(j).getY() + "},";
    				}
    				if(points.getCount()>0)
    					strResult = strResult.substring(0, strResult.length()-1);
    				strResult += "],\"area\":" + geo.getPreciseArea(PrjCoordSys.fromEPSG(4326)) + "},";//计算面积时应传入对应的坐标系类型
    			}
    			if(arrGeoResult.length>0)
    				strResult = strResult.substring(0, strResult.length()-1);
    		}
    		strResult += "]";
    
    		/*---------数据集及数据源等操作完毕后必须记得关闭,否则后面再打开会报错--------*/
    		/*ds.close();
    		dsv.close();
    		datasource.close();
    		ws.close();*/
    		
    		return strResult;
    	}
    }

           没有编译错误后将工程导出为jar包GeometryCaculate.jar。

           说明:上述代码编写完毕后如果想在eclipse里通过“Run As Java Application”启动main函数运行的话必须得有iObjects Java的运行许可。

           将上述jar包文件拷贝至iServer/WEB-INF/lib下:


           编辑supermap-iserver-9.0.1-win64-zip\webapps\iserver\WEB-INF\iserver-services.xml文件,在components节点下增加如下内容:


           启动iServer,然后访问iServer的服务列表:


           上图中红框里面的caculate/rest就是新开发的服务。访问服务后,出现如下结果:


           好了,大功告成!

           上面的代码中是将进行合并运算的多个面坐标写死到代码里了。实际中可根据需要将面坐标串定义为方法的参数,这样就可以在调用服务的时候传入了:

    public static String union(String strRegionsCoords){
       ......
    }

           通过这种方式接收到Geometry坐标字符串后,再在代码中自行解析坐标,然后再构造Geometry即可。


    展开全文
  • 最近总是碰到有人问Java如何访问SuperMap iServerJava6R的服务,由于目前SuperMap iServerJava6R不支持RMI访问访问,所以考虑使用Java直接访问REST的API。 环境准备: 1、开发工具 MyEclipse,服务器iServerJava6R 2...

    最近总是碰到有人问Java如何访问SuperMap iServerJava6R的服务,由于目前SuperMap iServerJava6R不支持RMI访问访问,所以考虑使用Java直接访问REST的API。

    环境准备:

    1、开发工具 MyEclipse,服务器iServerJava6R

    2、HttpComponents及Org.json类库,第一个http协议的开源Java客户端工具库,org.json是Json库,这两个都在iServerJava6R依赖库中,直接调用即可。如下图为所用类库,可以直接在iServerJava6R安装目录下\webapps\iserver\WEB-INF\lib找到:

    1

    3、iServerJava6R的REST API的文档

     

    开发思路:

    1、根据REST API构造参数类。

    2、调用HttpComponents发送请求,解析结果

    3、展现结果,一般使用地图

     

    实现一个简单的吧,就调用distance,量算距离,上代码吧:

    1、参数类,distance接口需要两个参数一个是Point2D数组,另外一个是一个枚举单位,我一般习惯使用以米为单位,所以直接用单位METER了。

    参数类/**
     * 参数类
     * @author awei20081
     *
     */
    public class Point2D {
       private double x ;
       private double y;
       public Point2D(double x,double y){
    	  this.x = x;
    	  this.y =y;
       }
    	public double getX() {
    		return x;
    	}
    	public void setX(double x) {
    		this.x = x;
    	}
    	public double getY() {
    		return y;
    	}
    	public void setY(double y) {
    		this.y = y; 
    	}
    }


    2、发送请求与解析,这里distance接口是一个get请求,所以构造调用HttpComponents的HttpGet对象,代码如下:

    请求发出与解析import java.net.URL;
    import java.net.URLEncoder;
    import java.util.ArrayList;
    import org.apache.http.HttpResponse;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.apache.http.util.EntityUtils;
    import org.json.JSONObject;
    
    public class getDemo {
    	public final static void main(String[] args) throws Exception {
    		//构建请求的URL
    		String url="http://localhost:8090/iserver/services/map-world/rest/maps/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE/distance.rjson?";		
    		//构造参数
    		ArrayList<Point2D> arrayList = new ArrayList<Point2D>();
    		arrayList.add(new Point2D(0,0));
    		arrayList.add(new Point2D(10,10));
    		//GET的URL,参数直接加URL后
    		URL uri = new URL(url+URLEncoder.encode("point2Ds="+toJSONArray(arrayList),"UTF-8")+"&unit=METER");
    		HttpGet httpget=new HttpGet(uri.toString());
    		//执行http的get请求
    		HttpResponse response=new DefaultHttpClient().execute(httpget);
    		//发送GET,并返回一个HttpResponse对象,相对于POST,省去了添加NameValuePair数组作参数
    		if(response.getStatusLine().getStatusCode()==200){//如果状态码为200,就是正常返回
    			String result=EntityUtils.toString(response.getEntity());
    			//得到返回的字符串
    			JSONObject jsresult = new JSONObject(result);
     			System.out.println("长度为"+jsresult.get("distance")+"  "+jsresult.getString("unit"));
    			//打印输出
    		}     
        }	
    	public static StringBuilder toJSONArray(ArrayList<Point2D> arrayList)
    	{
    		StringBuilder string = new StringBuilder();
    		string.append("[");
    		for (int i = 0; i < arrayList.size()-1; i++) {
    			JSONObject jsObject = new JSONObject(arrayList.get(i));
    			string.append(jsObject.toString()+",");
    		}
    		JSONObject jsObject = new JSONObject(arrayList.get(arrayList.size()-1));
    		string.append(jsObject.toString());
    		string.append("]");
    		return string;
    	}
    }

    备注:这个地方比较纠结,我第一用HttpComponents碰到比较多的问题列举如下阅读时候可以参考一下:

    (1)url可以直接获取,即http://localhost:8090/iserver/services/map-world/rest/maps/世界地图/distance.rjson,但是不能直接用,因为需要对中文进行编码,而且不能直接调用URLEncoder直接对这个url整体进行编码,此处我图简单直接对 世界地图 进行编码为:/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE,所以url为http://localhost:8090/iserver/services/map-world/rest/maps/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE/distance.rjson,可以逐段解析url进行编码。

    (2)、如果直接用org.json类库中JSONArray构造解析Point2D数组,解析结果不太对,所以我直接构造一个toJSONArray来对Point2D数组进行处理。
    (3)、默认浏览器对url进行编码处理时候使用的是utf-8编码,而且iServerJava6R对请求返回结果的编码为utf-8。

    3、结果展示,此处偷懒了直接调用println函数输出。

    长度为1570277.6641936298  METER

     

    上面只是一个简单的思路介绍,也许对高手很简单,但是毕竟初次学习,记录下来以备后查吧。

     

    转载于:https://www.cnblogs.com/awei20081/archive/2011/06/19/2084576.html

    展开全文
  • 是超图公司的教程之一,包括SuperMap iServer Java 层次结构,开发方式,二次开发等。适合初级开发者。
  • SuperMap 开发实例.java

    2020-06-27 16:51:25
    基于superMap 9D的iobject和isServer 完成的地图绘制编辑,具体为打开地图空间,数据集、图层的管理,线路的绘制,地图图片的输出
  • 超图公司的高级培训教程之一,SuperMap iServer Java扩展开发较为详细的简介,包括公交查询的实现等。
  • 基于java开发的gis技术,supermap,很稀缺的资源,希望对你有用
  • 一文了解SuperMap iDesktop Java定制开发

    千次阅读 2019-08-21 16:41:13
    SuperMap iDesktop Java(以下简称“Java桌面”)是超图的一款跨平台桌面GIS软件,兼容Windows和Linux。Java桌面采用插件式扩展开发框架,支持Java、Python两种语言扩展开发。今天,我们将为大家解密Java桌面中提供...

    SuperMap iDesktop Java(以下简称“Java桌面”)是超图的一款跨平台桌面GIS软件,兼容Windows和Linux。Java桌面采用插件式扩展开发框架,支持Java、Python两种语言扩展开发。今天,我们将为大家解密Java桌面中提供了哪些可以定制开发的内容,以及如何进行定制开发。

    开发环境配置

    Java桌面的扩展开发环境配置十分简单,只需在Windows或Linux系统中部署JDK 1.8环境,安装Java开发工具(推荐IDEA),即可进行扩展开发。

    除此之外,Java桌面也提供了扩展开发实例模板工程SampleCode,只需要在配置文件中进行简单的UI配置,就可实现扩展开发。

    Java桌面内置Python运行环境,提供Python IDE,因此基于Python的轻量级二次开发也很方便。

    开发环境配置完成后,你就可以基于Java桌面进行定制开发,搭建自己的应用系统。
    在这里插入图片描述
    界面功能定制

    Java桌面与经典的跨平台QT桌面不同,采用的是Ribbon UI的图形界面,通过配置文件(*.config)实现界面的布局、构建和绑定功能代码(一般为CtrlAction类)。因此,基于Java桌面开发的应用系统界面,只需要通过修改配置文件的方式就可以实现系统界面的布局,避免书写大量界面代码,方便快捷。
    在这里插入图片描述
    工具箱定制

    Java桌面的工具箱中已经提供了240+GIS工具。这些工具,不仅可以直接拿来使用,也可以通过Java语言、Python语言进行扩展,结合可视化建模使用,实现一键化的操作。

    使用Java语言进行工具定制,需要继承模型基类(MetaProcess类)实现对应的方法。界面配置方式则灵活多变,既可配置到Ribbon、右键菜单,也可配置到工具箱。
    在这里插入图片描述
    Java桌面支持通过内置的IDE编写Python脚本创建工具,也支持通过加载Python文件(*.py)的方式创建工具。在执行Python工具的同时,输出区会有对应的Python代码输出,方便及时跟踪代码的执行情况。
    在这里插入图片描述
    使用Python开发

    Java桌面中集成了数据处理、拓扑、插值、邻近分析等SuperMap iObjects Python功能,并且Java桌面的Python IDE支持Python编码风格,支持接口方法、参数的智能提示和自动补全,支持内嵌API的接口说明,可以很方便地使用Python语言进行轻量级功能定制。

    Python IDE和Java桌面做到了数据的互访问,在IDE中可以直接调用Java桌面打开数据,IDE的执行结果支持保存到数据源中,可以在地图、场景上进行可视化显示,执行结果一目了然。
    在这里插入图片描述
    经过上文的解密,想必你已经了解了Java桌面中定制开发的相关内容。如果你还想进一步的掌握这些知识点,点击文末『阅读原文』或复制以下链接至浏览器中查看,获取Java桌面下载地址,定制自己的应用系统:
    http://support.supermap.com.cn/DownloadCenter/ProductPlatform.aspx

    展开全文
  • 还是超图公司supermap的教程,大家可以看看,希望对大家有帮助
  • 目录 第一步:添加对 SuperMap iObjects Java 的 ... 为了方便在 Eclipse 开发环境中使用 SuperMap iObjects Java 提供的接口进行开发,用户可以按照以下方式将 SuperMap iObjects Java 程序员参考集成到 Eclipse ...

    目录

    第一步:添加对 SuperMap iObjects Java 的 jar 文件的引用

    第二步:为引用的 jar 文件指定帮助文档(Javadoc)


     

              为了方便在 Eclipse 开发环境中使用 SuperMap iObjects Java 提供的接口进行开发,用户可以按照以下方式将 SuperMap iObjects Java 程序员参考集成到 Eclipse 环境中,这样,就可以在编写程序代码的过程中,在 Eclipse 环境中查看 SuperMap iObjects Java 接口的使用说明,如下图所示。

    图:鼠标停留在接口上显示帮助

    第一步:添加对 SuperMap iObjects Java 的 jar 文件的引用

    在 Eclipse 环境中,在您的开发工程中添加对 SuperMap iObjects Java 的 jar 文件的引用,根据工程的需要引用相应功能的 jar 文件。具体操作流程如下。

    1. 选中工程,再点击【project】-【Properties】。(如果不选中工程,那么Properties是灰色的,不可选)
    2. 打开如下图所示的对话框,选择左侧树中的“Java Build Path”项,在右侧区域单击“Libraries”选项卡,然后,单击“Add External JARs...”按钮;
    3. 在打开的对话框中,选择工程所需要引用的 SuperMap iObjects Java 的 jar 文件,这里选择“com.supermap.data.jar”,单击“打开”按钮,然后,单击“OK”按钮完成对 jar 文件的引用。

    第二步:为引用的 jar 文件指定帮助文档(Javadoc)

    1. 如下图所示,在引用到工程中的 jar 文件上,右键鼠标,选择菜单中的“Properties”项;

    2.打开如下图所示的对话框,单击左侧树中的“Javadoc Location”项,然后,在右侧区域中指定 SuperMap iObjects Java 接口帮助的内容。

    这里提供了两种方式来指定接口的帮助内容,根据接口帮助内容的存储位置分为:在线帮助和本地帮助。其中:

    • 在线帮助方式:通过将 SuperMap 官方网站提供的 SuperMap iObjects Java 在线帮助中的程序员参考部分的帮助内容指定给所引用的jar文件,从而达到程序员参考与Eclipse集成的目的;如果该项目使用集成官网在线帮助,你只需要输入“http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iObjectsJava/ProgrammingReference/”即可
    • 本地帮助方式:SuperMap iObjects Java 安装目录下的 Help 文件夹中提供了 SuperMap iObjects Java Javadoc.zip 供程序员参考,解压该 zip 文件到当前文件夹,再点击【Browse...】,找到该解压后的文件夹地址即可,我这里是:D:\supermap-iobjectsjava-9.1.2-17224-71949-win-all\Help\SuperMap iObjects Java Javadoc  (注意:要用“Browse...”的方式,不要直接复制地址进去!)

    最终效果:

    展开全文
  • SuperMap Object Java 开发问题汇总(2012)

    千次阅读 2011-11-23 18:03:22
    一、开发Servlet服务 1.PrjCoordSys是objects中全局静态变量,不能释放,同时在创建一个新的PrjCoordSys的时候,需要用synchronized,否则会出现异步的问题。 2.DatasetVector在Servlet的单实例多线程中,不能释放...
  • 包括SuperMap iServer Java 层次结构、开发方式、二次开发(地图的基本浏览功能、地图量算、空间查询、属性查询、缓冲分析、最近地物查找、鹰眼功能)。个人觉得不错,跟大家分享。 还有一个(2),不是我恶意分开,...
  • 基于SuperMap Objects Java开发地图应用的入门介绍。
  • 准备用java对超图进行二次开发,但发现网上关于iobject java开发的相关资料很少,在此记录下超图iobject java开发前的准备事项。 到超图技术资源中心[http://support.supermap.com.cn/product/iObjects.aspx](选择...
  • 详细介绍supermap iobjects java组件的环境部署,及程序开发入门引导
  • 本范例示范了如何使用浏览器调用SuperMap Objects Java开发的Applet程序。
  • 这个是supermap开发文档,有需要的可以拿走,网上也有挺多,一般都没问题的,希望学习之路一切顺利,supermap功能确实强大,二次开发很有趣。
  • SuperMap iServer JAVA API介绍

    千次阅读 2017-04-17 11:51:04
    SuperMap iServer (以下简称iServer)的 JAVA API严格来说就是iServer JAVA类库提供的开发接口,为了区别于扩展iServer,我们说的JAVA API都是指:在其他应用中,引用iServer相关jar包进行开发的API(方式)。...
  • SuperMap iObjects Java 7C for Windows 运行环境与开发环境的部署
  • SuperMap IS Java介绍

    2008-07-05 18:15:39
    SuperMap iServer Java 2008是一款功能强大、性能稳定的服务式 GIS 开发平台。 该产品在服务器端,可以面向网络客户端提供与专业 GIS 桌面产品相同功能的 GIS 服务,能够管理、发布和无缝聚合Web 服务 、OGC 标准...
  • 使用 SuperMap iObjects Java/.NET 10i 产品需要 ...开发许可:主要面向二次开发用户,SuperMap iObjects Java/.NET 10i 开发许可包含了几乎所有功能的开发许可(其他功能的开发许可情况请参见下表)。 运行许可:用于
  • 目前超图supermap objects .net还没有发布,在超图平台上做三维采用B/S开发就只有用supermap objects java
  • 目录 数据库相关 制图相关 数据库相关 Q:超图数据库中图层名与数据集表名不对应 A:sdx中的smregister注册表中可以查看相应的数据集对应的表名 制图相关 Q:超图桌面端不同图层设置相同风格 ......
  • 我将开发环境配置好以后执行如下代码报错。请问我应该如何排查错误?Workspace workspace = new Workspace();报错信息Qt: Untested Windows version 10.0 detected!java.lang.IllegalStateException: connect types ...
  • 包括几个小实例,基于supermap is.net 开发GIS的小例子,Ajax,Java
  • SuperMap iClient for Silverlight开发准备

    千次阅读 2013-01-28 21:11:10
    由于年后可能要针对SuperMap进行GIS开发,特收集些资源,留作参考备用: 1、在线范例地址:...http
  • 分类专栏: SuperMap ObjectsJava开发 在使用SuperMap Objects Java开发web应用时,当将应用部署到Tomcat中运行时,当调用Objects中的方法时,以ObjectsJava 7为例,如果不做特殊处理一定会报下面这个错: java...
  • SuperMap iObjects Java在Tomact中的应用

    千次阅读 2016-07-15 17:34:11
    本博文主要以Web工程为切入点,介绍SuperMap iObjects Java在Web服务中的应用。下面的举例中开发平台使用MyEclipse ,发布服务的中间件使用Tomact,iObjects Java组件使用的是7.12,大家可以根据自己的项目需求来...
  • 一般集成SuperMap iServer Java 6到项目或者产品中采用war包的形式,而解压包和安装包多是开发环境使用。 war包优势: 1、不分平台限制,可以部署到Linux、Windows上(X86、X64)。 2、可以部署到各种中间件,Jboss...
  • SuperMap iDesktop Java中集成这个功能,在软件的工具箱中有很多集成好的数据处理和数据分析的可视化建模功能,如果里面没有找到项目中需要的,还可以通过Python来扩展开发,下面和大家分享一下在iDesktop Java中...

空空如也

空空如也

1 2 3 4
收藏数 79
精华内容 31
关键字:

java开发supermap

java 订阅