MapXtreme for Java entities and search

Source: Internet
Author: User
Tags unique id

A map entity is a map object on a map. such as dots, lines, or regions. In MapXtreme, the map entities are represented as Feature pairs
Like.

Methods of Feature objects
The Feature object's methods contain information about tabulation and geometry data. These methods are listed in the following table:
GetAttribute gets the specified property assigned to the column index.
Getattributecount gets the number of attributes associated with this entity.
Getgeometry gets the related geometry object and is empty if the entity has no geometry object.
Getlabelrendition gets the style specified for the callout for this entity. If no style is used for the callout, the return is null.
GetPrimaryKey Gets the PrimaryKey object (unique ID) for this entity. If the entity does not
PrimaryKey, a null value will be returned.
Getraster if present, returns the grid object associated with the entity and returns NULL if the entity has no grid.
Getrendition returns the style of this entity. If no style is used for the entity, the return is null. Each Feature object can have a rendition object. Rendition object describes the display characteristics of an entity

code example: getting information from an entity

Layers Layers = Mapj.getlayers ();
Layer Mylayer = Layers.getlayer ("Hunan");
Gets the layer table information Tableinfo mytableinfo = Mylayer.gettableinfo ();
Stores the Table property field vector<string> ColumnNames = new vector<string> ();
int columnCount = Mytableinfo.getcolumncount ();
String Col;
	for (int j = 0; J < ColumnCount; J + +) {col = Mytableinfo.getcolumnname (j);
Columnnames.addelement (COL); //Search searchall,searchwithinradius,searchwithinregion,//Searchwithinrectangle,searchatpoint Searchbyattribute/ /queryparams uses the Queryparams class to filter this information to improve the performance of the program//queryparams queryparams = new Queryparams (True, False,true,true, True,
True, Searchtype.entire);
FeatureSet fs = Layer.searchwithinregion (Cols,searchfeature.getgeometry (), queryparams);
Rewindablefeatureset features = new Rewindablefeatureset (mylayer. Searchall (ColumnNames, null));
Feature fistf = Features.getnextfeature ();
	while (FISTF!= null) {Geometry Geom = Fistf.getgeometry (); point:geometry.type_point=//1,line:geometry.type_line=2,polygon:type_region=3 if (geom.gettype () = = Geometry.type_point) {pointgeometry pntgeometry = (PointGeometry)
		Geom
		Doublerect rect = Pntgeometry.getbounds ();
	Doublepoint dblpnt = Pntgeometry.getcentroid ();
		else {vectorgeometry vectorgeometry = (vectorgeometry) geom;
		Doublerect rect = Vectorgeometry.getbounds ();
		double[] pnts = null;
		int offset = 0;
		int numpts; for (int i = 0; i < Vectorgeometry.getpointlistcount (); ++i) {Pointlist pntlist = vectorgeometry.getnextpointlist ()
			;
			numpts = Pntlist.getpointcount ();
			PNTs = new Double[numpts];
		Coordinate information, stored in array pntlist.getnextpoints (pnts, offset, NUMPTS/2);
		for (int j = 0; J < Pnts.length; J + +) {System.out.println (pnts[j]);
} FISTF = Features.getnextfeature (); }


Search: Use the search feature to retrieve specific data based on geographic information. For example, if you are looking for all base stations within a 25-metre radius, you will perform a search operation. Search is a method of Featurelayer objects. They return the FeatureSet object. The basic function of MapXtreme is to select an entity on the map so that other tasks can be performed on it. Users can click a map to select one or more entities (dots, lines, ranges, and so on). Search results are usually interpreted as selection. The following methods of Layer objects provide a variety of search layers and return featureset collections.
Searchall
Searchwithinradius
searchwithinregion
Searchwithinrectangle
Searchatpoint

(1), Searchall returns a FeatureSet collection of all the entities in the layer.
You can use this search method if your application needs to loop through the entire layer.
Mylayer.searchall (ColumnNames, queryparams.all_params); (2), Searchwithinradius returns the FeatureSet collection that forms the entity within the specified distance of the point object.
Use this search to find the most recent meal from a specified location, or to return the number of customers within a radius of a store.
Doublepoint Dblpt = new Doublepoint (-73.889444, 42.765555);
Double Dradius = 10.03;
FeatureSet fs = Mylayer.searchwithinradius (ColumnNames, Dblpt, Dradius, Linearunit.mile, queryparams.all_params); (3), Searchwithinregion returns a featureset set that forms an entity within the geometric range of an entity.
Use this method to return the number of customers within a specific area, such as a postal code, or to return an entity that is contained within a zone created with Featurefactory. 
Geometry Vgeom = null;//a region featureset VFS = mylayer.searchwithinregion (ColumnNames, Vgeom, queryparams.all_params); (4), Searchwithinrectangle returns the collection of FeatureSet within the specified rectangle boundary.
Use this method to search or check the zoom level within a given map window to see if it contains some points to focus on.
Doublerect drect = new Doublerect (-74.092662, 42.765555, -73.668898,42.856420);
FeatureSet dfs = Mylayer.searchwithinrectangle (columnnames, drect,queryparams.all_params); (5), Searchatpoint returns the FeatureSet collection that constitutes the entity at the specified point.
Use this method to test all objects that intersect a point. Doublepoint DP = NEW Doublepoint (12.3456,-67.890);
FeatureSet PFS = Mylayer.searchatpoint (ColumnNames, DP, queryparams.all_params); (6), Searchbyattribute returns a collection of FeatureSet whose properties match the given property. Use this method to select all entities with public property information.
For example, if you have a table that contains a family income column, you can use Searchbyattribute to return all records with a family income equal to 100,000 dollars.
Attribute mysearchattr = new attribute (100000);
String Searchcol = "Annual_income"; FeatureSet AFS = Mylayer.searchbyattribute (ColumnNames, Searchcol, mysearchattr, NULL);


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.