====== Map Suite Android Geometric Functions ====== ===== Video Overview ===== {{youtube>SUqBu5Yu4n8?large|Android Geometric Functions Video Overview}} == Geometric Functions ==
{{filehistory:AndroidEditionSample_GeometricFunctions_141211.zip|C# Project}} [[Source_Code_AndroidEditionSample_GeometricFunctions.zip|View Source]]
== Geometric Functions(Xamarin Forms) ==
{{filehistory:MapSuiteFormsEdition_GeometricFunc.zip|C# Project}} [[Source_Code_XamarinFormsEditionSample_GeometricFunctions.zip|View Source]]
===== Introduction ===== The Map Suite Android Geometric Functions Learning Sample shows some of the most popular ways you can manipulate points, lines, and polygons. For this sample, press the “Go” button in the upper-right corner to run the selected geometric function. ===== Union ===== The Union function merges two or more existing feature shapes into one feature. Any overlapping features on the map will be merged together into one continuous shape. To do this, select the feature you'd like to add the other features to. This might be the feature with the name, ID, or other attribute data you'd like to retain. In the image below, multiple polygon features (left) are merged into a single polygon feature (right). [[ThinkGeo.MapSuite.Core.EditTools#Union.28String.2C_Feature.29|More information.]] {{androidedition: union_thumb.png|Border}} If you like, developers can also set the Union function up to work with multiple layers. When configured this way, a union will combine all the features and geographical extents of two layers. For example, in the image below, the Union function combines two separate but overlapping layers (left) into a single new output layer. [[ThinkGeo.MapSuite.Core.EditTools#Union.28String.2C_AreaBaseShape.29|More information.]] {{androidedition: union2_thumb.png|Border}} ===== Difference ===== The Difference function compares two features and cuts out the overlapping area of the target feature from the original feature, creating a resultant feature. [[ThinkGeo.MapSuite.Core.EditTools#GetDifference.28String.2C_Feature.29|More information.]] {{androidedition: difference2_thumb.png|border}} You can also set the Difference function up to work with multiple layers. When configured this way, the Difference function will create a new layer made from cutting the target layer out of the original layer. Note that the two input layers must have the same geometry type (polygon, line or point). [[ThinkGeo.MapSuite.Core.EditTools#GetDifference.28String.2C_AreaBaseShape.29|More information.]] ===== Buffer ===== Buffer draws a polygon extending a given distance around a set of features, or a single feature. The buffer can have square or rounded corners. For example, you might want to create a buffer area representing flood hazard zones that extends for 3 miles in each direction around rivers, streams, and creeks, or you might want to visualize a non-compete zone within 10 miles of a business. You can buffer any type of feature - point, line, or polygon. In the image below, notice that the yellow buffer on the right extends slightly beyond the polygon's boundaries. {{androidedition: buffer_thumb.png|border}} Choose to buffer all of a layer's features, or only selected feature(s). **Dissolve Buffers** You can dissolve buffers to remove the borders of overlapping buffer zones. {{androidedition: dissolve_thumb.png|border}} **Negative Buffers** You can also input a negative buffer distance to create buffers inside polygons. ===== Scale ===== This function scales a feature up or down by a percentage centered on the centroid, or geometric center. In other words, it changes a feature's size to make it larger or smaller. [[ThinkGeo.MapSuite.Core.EditTools#ScaleDown.28String.2C_Double.29|More information.]] {{androidedition: scale_thumb.png|border}} ===== Rotate ===== This function rotates the shape by a number of degrees. [[ThinkGeo.MapSuite.Core.EditTools#Rotate.28String.2C_PointShape.2C_Single.29|More information.]] {{androidedition: rotate_thumb.png|border}} ===== Center Point ===== Center Point returns the centroid of a polygon or the center of a line. This sample also shows the center of the Bounding Box, which is the rectangle that fits around the feature. {{androidedition: centerpoint_thumb.png|border}} ===== Area Calculation ===== The Area Calculation function calculates and displays the area of a polygon feature. Our sample shows the area in hectares and acres, but you could modify the function to show the area in any units you desire. {{androidedition: area-calc-thumb.png|border}} ===== Simplify ===== Takes a complex polygon and reduces the number of sides so that the new polygon is an estimate of the original. Complex polygons can be processor intensive, so if you only require an estimate, Simplify can increase performance. {{androidedition: simplify_thumb.png|border}} ===== Get Shortest Line ===== Calculates the distance between 2 features. With complex polygons, it’s not always apparent what the shortest line is to human eyes. Can also be used to find the shortest distance between points and lines. {{androidedition: shortest-line_thumb.png|border}} ===== Length Calculation ===== Shows the lengths of a line. Can be in feet or meters. Of course, you could modify the function to show kilometers or miles. {{androidedition: length_thumb.png|border}} ===== Get Line on a Line ===== Creates a new line based upon a subset of the line. For example, if there is a chemical spill on a road, and you need to shut down the road 1000 feet around it, you could create a buffer around the point. Then, where the buffer intersects with the road is the location of where the roadblock needs to be. Use “Get Line on a Line” to highlight the section of the road that is impassible. {{androidedition: line-on-line_thumb.png|border}} ===== Clip ===== The Clip function clips or crops a layer's extent to match the extent of another layer. For example, you could use the Clip tool to crop a layer of state highways (input feature) to the extent of a layer covering only a single county (clip feature). Layers do not need to share the same geometry type. In our example, the blue polygon is the cookie-cutter. Upon running, only the features inside the polygon remain. You could modify the function to perform the inverse and only leave the features outside of the polygon. {{androidedition: clip_thumb.png|border}} ===== Convexhull ===== Convexhull encapsulates all points or polygons inside a perimeter. In our example, there are 5 fires in a field. Use Convexhull to highlight the burn area. There is also a shape with rounded edges and concave portions. Convexhull is used to surround the shape and finish with no concave sections. {{androidedition: convexhull_thumb.png|border}} ===== Envelope Boundingbox ===== Have an irregularly-shaped polygon? Envelope Boundingbox displays the rectangle that surrounds it. This is helpful so you can zoom into that feature. You can also create a rectangle around multiple features. This tool can be useful for representing the footprints of buildings or parcels of land. {{androidedition: last_thumb.png|border}} ===== Snapping ===== If a vertex is within a certain radius of another feature, snapping aligns them. If you’ve traced a road based upon aerial imagery, use Snapping to line up the points. In our example, the left vertex is within the radius and will snap to the line, while the right vertex is not within the radius and therefore will not snap. {{androidedition: snapping_thumb.png|border}} ===== A Look at the Code ===== SplashActivity is the MainLauncher, meaning that it will run when the program is opened and display the splash screen. After checking for the sample data, MainActivity is called. MainActivity.cs includes SliderView, which sets up the sliding menu, and ListView, which is a Xamarin class used to show the Style List in the menu. In the SampleListView_ItemClick function, the activitySample is set to the style that was tapped. BaseSample is the base class of all the samples. Title sets the header at the top of the screen. MapView is the Map Suite map controller. Each of the style samples have an InitializeMap function that sets up the map for display and an Execute function which executes the geometric function.