<commit_before>/* ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of Weave.
 *
 * The Initial Developer of Weave is the Institute for Visualization
 * and Perception Research at the University of Massachusetts Lowell.
 * Portions created by the Initial Developer are Copyright (C) 2008-2015
 * the Initial Developer. All Rights Reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 * ***** END LICENSE BLOCK ***** */

package weave.primitives
{
	import flash.utils.Dictionary;
	
	import weave.api.data.ISimpleGeometry;
	import weave.api.primitives.IBounds2D;
	import weave.utils.BLGTreeUtils;
	import weave.utils.GeoJSON;
	import weave.utils.VectorUtils;
	
	/**
	 * GeneralizedGeometry
	 * A generalized geometry is one that lends itself to be displayed at different quality levels.
	 * The geometry coordinates may be inserted individually through the "coordinates" property,
	 * or they can all be processed at once through the setCoordinates() function.
	 * The bounds object is separate from the coordinates, so if coordinates are inserted individually,
	 * the bounds object should be updated accordingly if you want it to be accurate.
	 * 
	 * @author adufilie
	 */
	public class GeneralizedGeometry 
	{
		/**
		 * Create an empty geometry.
		 * @param geomType The type of the geometry (GeometryType.LINE, GeometryType.POINT, or GeometryType.POLYGON).
		 */
		public function GeneralizedGeometry(geomType:String = GeometryType.POLYGON)
		{
			this.geomType = geomType;
			this.parts[0] = new BLGTree();
		}
		
		/**
		 * Generates a GeoJson Geometry object.
		 * @param minImportance No points with importance less than this value will be returned.
		 * @param visibleBounds If not null, this bounds will be used to remove unnecessary offscreen points.
		 * @return A GeoJson Geometry object.
		 */
		public function toGeoJson(minImportance:Number = 0, visibleBounds:IBounds2D = null):Object
		{
			var type:String = GeometryType.toGeoJsonType(geomType, true); // Multi- geoms can represent non-Multi geoms
			var coords:Array = [];
			var parts:Vector.<Vector.<BLGNode>> = getSimplifiedGeometry(minImportance, visibleBounds);
			var part:Vector.<BLGNode>;
			var node:BLGNode;
			
			//TODO - http://geojson.org/geojson-spec.html#geometry-objects
			if (type == GeoJSON.T_MULTI_POINT)
			{
				for each (part in parts)
					for each (node in part)
						coords.push([node.x, node.y]);
			}
			else if (type == GeoJSON.T_MULTI_LINE_STRING)
			{
				for each (part in parts)<commit_msg>removed todo comment<commit_after>/* ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of Weave.
 *
 * The Initial Developer of Weave is the Institute for Visualization
 * and Perception Research at the University of Massachusetts Lowell.
 * Portions created by the Initial Developer are Copyright (C) 2008-2015
 * the Initial Developer. All Rights Reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 * ***** END LICENSE BLOCK ***** */

package weave.primitives
{
	import flash.utils.Dictionary;
	
	import weave.api.data.ISimpleGeometry;
	import weave.api.primitives.IBounds2D;
	import weave.utils.BLGTreeUtils;
	import weave.utils.GeoJSON;
	import weave.utils.VectorUtils;
	
	/**
	 * GeneralizedGeometry
	 * A generalized geometry is one that lends itself to be displayed at different quality levels.
	 * The geometry coordinates may be inserted individually through the "coordinates" property,
	 * or they can all be processed at once through the setCoordinates() function.
	 * The bounds object is separate from the coordinates, so if coordinates are inserted individually,
	 * the bounds object should be updated accordingly if you want it to be accurate.
	 * 
	 * @author adufilie
	 */
	public class GeneralizedGeometry 
	{
		/**
		 * Create an empty geometry.
		 * @param geomType The type of the geometry (GeometryType.LINE, GeometryType.POINT, or GeometryType.POLYGON).
		 */
		public function GeneralizedGeometry(geomType:String = GeometryType.POLYGON)
		{
			this.geomType = geomType;
			this.parts[0] = new BLGTree();
		}
		
		/**
		 * Generates a GeoJson Geometry object.
		 * @param minImportance No points with importance less than this value will be returned.
		 * @param visibleBounds If not null, this bounds will be used to remove unnecessary offscreen points.
		 * @return A GeoJson Geometry object.
		 */
		public function toGeoJson(minImportance:Number = 0, visibleBounds:IBounds2D = null):Object
		{
			var type:String = GeometryType.toGeoJsonType(geomType, true); // Multi- geoms can represent non-Multi geoms
			var coords:Array = [];
			var parts:Vector.<Vector.<BLGNode>> = getSimplifiedGeometry(minImportance, visibleBounds);
			var part:Vector.<BLGNode>;
			var node:BLGNode;
			
			if (type == GeoJSON.T_MULTI_POINT)
			{
				for each (part in parts)
					for each (node in part)
						coords.push([node.x, node.y]);
			}
			else if (type == GeoJSON.T_MULTI_LINE_STRING)
			{
				for each (part in parts)
{'fraction_non_alphanumeric': 0.0898919021429926, 'fraction_numerical': 0.006068651621467855, 'mean_word_length': 3.696349065004452, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7054559', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1489, 'n_words': 563}