/// <summary> /// This create new method implies that this provider has the priority for creating a new file. /// An instance of the dataset should be created and then returned. By this time, the fileName /// will already be checked to see if it exists, and deleted if the user wants to overwrite it. /// </summary> /// <param name="fileName">The string fileName for the new instance</param> /// <param name="featureType">Point, Line, Polygon etc. Sometimes this will be specified, sometimes it will be "Unspecified"</param> /// <param name="inRam">Boolean, true if the dataset should attempt to store data entirely in ram</param> /// <param name="progressHandler">An IProgressHandler for status messages.</param> /// <returns>An IRaster</returns> public virtual IFeatureSet CreateNew(string fileName, FeatureType featureType, bool inRam, IProgressHandler progressHandler) { if (featureType == FeatureType.Point) { PointShapefile ps = new PointShapefile(); ps.Filename = fileName; return ps; } else if (featureType == FeatureType.Line) { LineShapefile ls = new LineShapefile(); ls.Filename = fileName; return ls; } else if (featureType == FeatureType.Polygon) { PolygonShapefile ps = new PolygonShapefile(); ps.Filename = fileName; return ps; } else if (featureType == FeatureType.MultiPoint) { MultiPointShapefile mps = new MultiPointShapefile(); mps.Filename = fileName; return mps; } return null; }
public string GetLinkColor(FeatureType featureType) { DgmlColorConfiguration dgmlColor = new DgmlColorConfiguration(); string color = string.Empty; switch (featureType) { case FeatureType.Feature: case FeatureType.NeededFeature: color = dgmlColor.FeatureColor; break; case FeatureType.NeededExtensions: color = dgmlColor.NeededExtensionsColor; break; case FeatureType.Module: color = dgmlColor.ModuleColor; break; case FeatureType.BindingInterface: color = dgmlColor.BindingInterfaceColor; break; case FeatureType.BindingImpl: color = dgmlColor.BindingImplColor; break; } return color; }
public DataTable GetFeatures(FeatureType featureType, IGeometry spatialConstraint) { DataTable table = null; string layerId = featureType == FeatureType.Selection ? _appState.SelectionLayer : _appState.TargetLayer; if (layerId.Length > 0) { Configuration config = AppContext.GetConfiguration(); Configuration.LayerRow layerRow = config.Layer.FindByLayerID(layerId); CommonDataFrame dataFrame = AppContext.GetDataFrame(_appState.MapTab); CommonLayer layer = dataFrame.Layers.FirstOrDefault(lyr => String.Compare(lyr.Name, layerRow.LayerName, true) == 0); string query = GetQuery(featureType, layerRow, layer); if (query != null) { CommonField keyField = layer.FindField(layerRow.KeyField); if (spatialConstraint == null) { table = layer.GetFeatureTable(String.Format("{0},{1}", layer.GeometryField.Name, keyField.Name), query); } else { table = layer.GetFeatureTable(String.Format("{0},{1}", layer.GeometryField.Name, keyField.Name), query, spatialConstraint); } } } return table; }
public Envelope GetExtent(FeatureType featureType) { Envelope extent = new Envelope(); string layerId = featureType == FeatureType.Selection ? _appState.SelectionLayer : _appState.TargetLayer; Configuration config = AppContext.GetConfiguration(); Configuration.LayerRow layerRow = config.Layer.FindByLayerID(layerId); CommonDataFrame dataFrame = AppContext.GetDataFrame(_appState.MapTab); CommonLayer layer = dataFrame.Layers.FirstOrDefault(lyr => String.Compare(lyr.Name, layerRow.LayerName, true) == 0); string query = GetQuery(featureType, layerRow, layer); if (query != null) { extent = layer.GetFeatureExtent(query); } if (!extent.IsNull && extent.Width == 0 && extent.Height == 0) { extent = new Envelope(new Coordinate(extent.MinX - 50, extent.MinY - 50), new Coordinate(extent.MaxX + 50, extent.MaxY + 50)); } return extent; }
public EnableFeatureInfoRec GetFeatureInfo(DBManager dbManager, FeatureType type, string subType) { using (IDBProvider dbInstance = SP.DB.GetInstance(dbManager)) { return dbInstance._<EnableFeatureAccessor>().SelectInfoByType(GetFeatureTypeKey(type, subType)); } }
public Feature(string name, FeatureType featureType) { Name = name; FType = featureType; MinRound = Rounds.PREFLOP; MaxRound = Rounds.RIVER; }
public EnergyEventStatus(DeviceBase device, FeatureType featureType, uint featureId, int frequency, ObservableCollection<DeviceEventSettings> emitEvents) : base(device, featureType, featureId, frequency, emitEvents) { EnergyTotal = 0.0; EventPower = 0; LastPowerEmitted = 0; LastEnergyEmitted = 0.0; }
/// <summary> /// Creates a new instance of a shapefile based on a fileName /// </summary> /// <param name="fileName">File name</param> /// <param name="featureType">Feature type</param> protected Shapefile(string fileName, FeatureType featureType) : base(featureType) { Attributes = new AttributeTable(); Header = new ShapefileHeader(); Open(fileName, null); }
/// CHECKED /// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="w"></param> /// <param name="h"></param> public Feature(FeatureType type, int x, int y, int w, int h) { this.type = type; this.x = x; this.y = y; this.w = w; this.h = h; }
public FeatureInfo(System.Type feature, [NullGuard.AllowNull]System.Type factory, [NullGuard.AllowNull] System.Collections.Generic.IEnumerable<System.Type> dependencies, FeatureType featureType) { this.Id = System.Guid.NewGuid().ToString(); this.Feature = feature; this.Factory = factory; this.Dependencies = dependencies; this.FeatureType = featureType; this.dependenciesInfo = new System.Collections.Generic.List<FeatureInfo>(); this.BindingTarget = Planning.Bindings.BindingTarget.Self; }
public FeatureInfo(Type feature, [AllowNull]Type factory, [AllowNull]IEnumerable<Type> dependencies, FeatureType featureType) { this.Id = Guid.NewGuid().ToString(); this.Feature = feature; this.Factory = factory; this.Dependencies = dependencies; this.FeatureType = featureType; this.dependenciesInfo = new List<FeatureInfo>(); this.BindingTarget = BindingTarget.Self; }
private string featureTypeSubKey(FeatureType featureType) { switch (featureType) { case FeatureType.Point: return "points"; case FeatureType.Polyline: return "polylines"; case FeatureType.Polygon: return "polygons"; } return string.Empty; }
public bool Enable(DBManager dbManager, FeatureType type, string subType, bool isManually, string command, string text) { return DoUpdate(dbManager, new EnableFeatureRec { Type = GetFeatureTypeKey(type, subType), IsEnabled = true, IsManually = isManually, AuthorUserID = SP.SessionContext.UserID, Command = command, Text = text, Upd = DateTime.Now, }); }
public XElement GenerateLink(string sourceElementId, FeatureInfo targetElement, FeatureType featureType) { string color = this.colorSelector.GetLinkColor(featureType); XAttribute label = string.IsNullOrEmpty(targetElement.BindingTarget.ToString()) ? new XAttribute("Label", featureType) : new XAttribute("Label", "Binding " + targetElement.BindingTarget); var link = new XElement( this.nameSpace + "Link", new XAttribute("Source", sourceElementId), new XAttribute("Target", targetElement.Id), new XAttribute("Stroke", color), new XAttribute("StrokeDashArray", "3"), label); return link; }
/// <summary> /// Not Implemented yet /// </summary> /// <param name="fileName"></param> /// <param name="featureType"></param> /// <param name="inRam"></param> /// <param name="container"></param> /// <param name="progressHandler"></param> /// <returns></returns> public IFeatureLayer CreateNew(string fileName, FeatureType featureType, bool inRam, ICollection<ILayer> container, IProgressHandler progressHandler) { ShapefileDataProvider dp = new ShapefileDataProvider(); IFeatureSet fs = dp.CreateNew(fileName, featureType, inRam, progressHandler); if (progressHandler == null) progressHandler = LayerManager.DefaultLayerManager.ProgressHandler; if (fs.FeatureType == FeatureType.Line) { return new MapLineLayer(fs, container); } if (fs.FeatureType == FeatureType.Polygon) { return new MapPolygonLayer(fs, container); } if (fs.FeatureType == FeatureType.Point || fs.FeatureType == FeatureType.MultiPoint) { return new MapPointLayer(fs, container); } return null; }
protected FacetFactoryAbstract(int numericOrder, FeatureType featureTypes) { NumericOrder = numericOrder; this.featureTypes = featureTypes; }
public IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification, FeatureType featureType, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { foreach (var facetFactory in GetFactoryByFeatureType(featureType)) { metamodel = facetFactory.Process(reflector, property, specification, metamodel); } return(metamodel); }
/// <summary> /// StartRange, count and vertices will be declared later. /// </summary> /// <param name="featureType"></param> public PartRange(FeatureType featureType) { _segments = new SegmentRange(this, featureType); }
public void SetFeatureType(FeatureType type) { fType = type; GetComponent <Animator>().SetInteger("FeatureType", (int)fType); }
protected AnnotationBasedFacetFactoryAbstract(int numericOrder, ILoggerFactory loggerFactory, FeatureType featureTypes, ReflectionType reflectionTypes = ReflectionType.ObjectOriented) : base(numericOrder, loggerFactory, featureTypes, reflectionTypes) { }
public IFeatureSet CreateNew(string fileName, FeatureType featureType, bool inRam, IProgressHandler progressHandler) { throw new NotImplementedException(); }
/// <summary> /// Attempts to read in an entry to the specified feature type. If the feature type does not match /// the geometry type, this will return null. (A Point geometry will be accepted by MultiPoint /// feature type, but not the other way arround. Either way, this will advance the reader /// through the shape feature. Using the Unspecified will always return the shape it reads, /// or null in the case of mixed feature collections which are not supported. /// </summary> /// <param name="data"></param> /// <param name="featureType"></param> /// <returns></returns> public static Shape ReadShape(Stream data, FeatureType featureType) { _endian = (ByteOrder)data.ReadByte(); WKBGeometryTypes type = (WKBGeometryTypes)ReadInt32(data); Shape result; switch (type) { case WKBGeometryTypes.WKBPoint: result = ReadPoint(data); if (featureType == FeatureType.Point || featureType == FeatureType.MultiPoint || featureType == FeatureType.Unspecified) { return(result); } return(null); case WKBGeometryTypes.WKBLineString: result = ReadLineString(data); if (featureType == FeatureType.Line || featureType == FeatureType.Unspecified) { return(result); } return(null); case WKBGeometryTypes.WKBPolygon: result = ReadPolygon(data); if (featureType == FeatureType.Polygon || featureType == FeatureType.Unspecified) { return(result); } return(null); case WKBGeometryTypes.WKBMultiPoint: result = ReadMultiPoint(data); if (featureType == FeatureType.MultiPoint || featureType == FeatureType.Unspecified) { return(result); } return(null); case WKBGeometryTypes.WKBMultiLineString: result = ReadMultiLineString(data); if (featureType == FeatureType.Line || featureType == FeatureType.Unspecified) { return(result); } return(null); case WKBGeometryTypes.WKBMultiPolygon: result = ReadMultiPolygon(data); if (featureType == FeatureType.Polygon || featureType == FeatureType.Unspecified) { return(result); } return(null); case WKBGeometryTypes.WKBGeometryCollection: throw new ArgumentException("Mixed shape type collections are not supported by this method."); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="Shape"/> class where the shaperange exists and has a type specified. /// </summary> /// <param name="featureType">Feature type of the shape range.</param> public Shape(FeatureType featureType) { Range = new ShapeRange(featureType); }
/// <summary> /// 获取最新的提到登录用户的微博列表,即@我的微博 /// </summary> /// <param name="since_id">若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。</param> /// <param name="max_id">若指定此参数,则返回ID小于或等于max_id的微博,默认为0。</param> /// <param name="count">单页返回的记录条数,最大不超过200,默认为20。</param> /// <param name="page">返回结果的页码,默认为1。</param> /// <param name="filter_by_author">作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。</param> /// <param name="filter_by_source">来源筛选类型,0:全部、1:来自微博、2:来自微群,默认为0。</param> /// <param name="filter_by_type">原创筛选类型,0:全部微博、1:原创的微博,默认为0。</param> /// <returns></returns> public static async Task <MessageListModel> GetMentions(long since_id = 0, long max_id = 0, int count = 20, int page = 1, AuthorType filter_by_author = AuthorType.All, SourceType filter_by_source = SourceType.All, FeatureType filter_by_type = FeatureType.All) { Dictionary <string, string> param = new Dictionary <string, string>() { { nameof(since_id), since_id.ToString() }, { nameof(max_id), max_id.ToString() }, { nameof(count), count.ToString() }, { nameof(page), page.ToString() }, { nameof(filter_by_author), filter_by_author.ToString("D") }, { nameof(filter_by_source), filter_by_source.ToString("D") }, { nameof(filter_by_type), filter_by_type.ToString("D") }, }; return(JsonConvert.DeserializeObject <MessageListModel>(await HttpHelper.GetStringAsync(Constants.MENTIONS, param))); }
private T GetFeatureConfig <T>(FeatureType type) where T : Configuration.WebhookObject { return((T)_config.FeatureTypes[type]); }
public MapTypeStyleBuilder FeatureType(FeatureType value) { this.Style.FeatureType = value; return(this); }
private IList <IFunctionalFacetFactoryProcessor> GetFactoryByFeatureType(FeatureType featureType) => factoriesByFeatureType[featureType];
private Feature ReadAttribute() { string attributeName = ReadToken(endOfLine: false); string typeString = ReadToken(endOfLine: false, quoting: false); FeatureType attributeType; if (string.Equals(typeString, "integer", StringComparison.OrdinalIgnoreCase)) { attributeType = FeatureType.Integer; ReadToken(endOfLine: true); } else if (string.Equals(typeString, "numeric", StringComparison.OrdinalIgnoreCase) || string.Equals(typeString, "real", StringComparison.OrdinalIgnoreCase)) { attributeType = FeatureType.Numeric; ReadToken(endOfLine: true); } else if (string.Equals(typeString, "string", StringComparison.OrdinalIgnoreCase)) { attributeType = FeatureType.String; ReadToken(endOfLine: true); } else if (string.Equals(typeString, "date", StringComparison.OrdinalIgnoreCase)) { string dateFormat = ReadToken(); if (dateFormat == null) { attributeType = FeatureType.Date(); } else { attributeType = FeatureType.Date(dateFormat); ReadToken(endOfLine: true); } } else if (typeString == "{") { List <string> nominalValues = new List <string>(); while (true) { string value = ReadToken(out bool quoted, endOfLine: false); if (!quoted && value == "}") { break; } else if (!quoted && value == ",") { continue; } else { nominalValues.Add(value); } } attributeType = FeatureType.Nominal(nominalValues); ReadToken(endOfLine: true); } else if (string.Equals(typeString, "relational", StringComparison.OrdinalIgnoreCase)) { ReadToken(endOfLine: true); List <Feature> childAttributes = new List <Feature>(); while (true) { string token = ReadToken(skipEndOfLine: true, endOfLine: false, quoting: false); if (string.Equals(token, "@attribute", StringComparison.OrdinalIgnoreCase)) { Feature attribute = ReadAttribute(); childAttributes.Add(attribute); } else if (string.Equals(token, "@end", StringComparison.OrdinalIgnoreCase)) { ReadToken(expectedToken: attributeName, endOfLine: false); ReadToken(endOfLine: true); break; } else { throw new InvalidDataException($"Unexpected token \"{token}\". Expected \"@attribute\" or \"@end\"."); } } attributeType = FeatureType.Relational(childAttributes); } else { throw new InvalidDataException($"Unexpected token \"{typeString}\". Expected attribute type."); } return(new Feature(attributeName, attributeType)); }
/// ------------------------------------------------------------------------------------------------- /// <summary> Runs a product handler depending on the type </summary> /// <param name="builder"></param> /// <param name="featureType"> Type of the product. </param> /// <param name="serviceTypes"> List of types of the services. </param> /// ------------------------------------------------------------------------------------------------- public static void RegisterDependencies(ContainerBuilder builder, FeatureType featureType, ServiceTypes serviceTypes) { ProductHandlers[featureType].Run(builder, serviceTypes); }
private object ParseValue(string value, bool quoted, FeatureType attributeType) { if (!quoted && value == "?") { return(null); } if (attributeType == FeatureType.Integer) { if (!int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int d)) { throw new InvalidDataException($"Unrecognized data value: \"{value}\""); } return(d); } else if (attributeType == FeatureType.Numeric) { if (!double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out double d)) { throw new InvalidDataException($"Unrecognized data value: \"{value}\""); } return(d); } else if (attributeType == FeatureType.String) { return(value); } else if (attributeType is NominalFeature nominalAttribute) { int index = nominalAttribute.Values.IndexOf(value); if (index == -1) { throw new InvalidDataException($"Unrecognized data value: \"{value}\""); } return(index); } else if (attributeType is DateFeature dateAttribute) { if (!DateTime.TryParseExact(value, dateAttribute.DateFormat, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out DateTime d)) { throw new InvalidDataException($"Unrecognized data value: \"{value}\""); } return(d); } else if (attributeType is RelationalFeature relationalAttribute) { List <Instance> relationalInstances = new List <Instance>(); using (StringReader stringReader = new StringReader(value)) while (true) { // weights for relational instances are currently discarded Instance instance = ReadInstance(out double?instanceWeight, relationalAttribute.ChildFeatures, stringReader); if (instance == null) { break; } relationalInstances.Add(instance); } return(relationalInstances.ToArray()); } else { throw new ArgumentException("Unsupported ArffAttributeType.", nameof(attributeType)); } }
/// <summary> /// StartRange, count and vertices will be declared later. /// </summary> /// <param name="featureType"></param> public PartRange(FeatureType featureType) { // _featureType = featureType; }
internal TemplatePickedEventArgs(FeatureLayer layer, FeatureType featureType, FeatureTemplate featureTemplate) { Layer = layer; FeatureType = featureType; FeatureTemplate = featureTemplate; }
public static bool Telekinesis(bool cast, Actor user, Tile t) { bool wand = !cast; if (t == null) { return(false); } if (t != null) { if (wand && user == player && !Item.identified[ConsumableType.TELEKINESIS]) { Item.identified[ConsumableType.TELEKINESIS] = true; B.Add("(It was a wand of telekinesis!) "); B.PrintAll(); } List <Tile> ai_line = null; if (user != player && t == player.tile()) { var fires = user.TilesWithinDistance(12).Where(x => x.passable && x.actor() == null && x.Is(FeatureType.FIRE) && user.CanSee(x) && player.HasBresenhamLineWithCondition(x, false, y => y.passable && y.actor() == null)); if (fires.Count > 0) { ai_line = player.GetBestExtendedLineOfEffect(fires.Random()); } else { if (wand) { ai_line = player.GetBestExtendedLineOfEffect(user); } else { ai_line = player.GetBestExtendedLineOfEffect(player.TileInDirection(Global.RandomDirection())); } } } Actor a = t.actor(); if (a == null && t.inv == null && !t.Is(FeatureType.GRENADE) && t.Is(FeatureType.TROLL_CORPSE, FeatureType.TROLL_BLOODWITCH_CORPSE)) { ActorType troll_type = t.Is(FeatureType.TROLL_CORPSE)? ActorType.TROLL : ActorType.TROLL_BLOODWITCH; FeatureType troll_corpse = t.Is(FeatureType.TROLL_CORPSE)? FeatureType.TROLL_CORPSE : FeatureType.TROLL_BLOODWITCH_CORPSE; Event troll_event = Q.FindTargetedEvent(t, EventType.REGENERATING_FROM_DEATH); troll_event.dead = true; Actor troll = Actor.Create(troll_type, t.row, t.col); foreach (Event e in Q.list) { if (e.target == troll && e.type == EventType.MOVE) { e.tiebreaker = troll_event.tiebreaker; e.dead = true; break; } } Actor.tiebreakers[troll_event.tiebreaker] = troll; troll.symbol = '%'; troll.attrs[AttrType.CORPSE] = 1; troll.SetName(troll.name + "'s corpse"); troll.curhp = troll_event.value; troll.attrs[AttrType.PERMANENT_DAMAGE] = troll_event.secondary_value; troll.attrs[AttrType.NO_ITEM]++; t.features.Remove(troll_corpse); a = troll; } if (a != null) { string msg = "Throw " + a.TheName(true) + " in which direction? "; if (a == player) { msg = "Throw yourself in which direction? "; } List <Tile> line = null; if (user == player) { TargetInfo info = a.GetTarget(false, 12, 0, false, true, false, msg); if (info != null) { line = info.extended_line; } } else { line = ai_line; } if (line != null) { if (line.Count == 1 && line[0].actor() == user) { if (wand) { return(true); } return(false); } if (cast) { B.Add(user.You("cast") + " telekinesis. ", user); if (a.type == ActorType.ALASI_BATTLEMAGE && !a.HasSpell(SpellType.TELEKINESIS)) { a.curmp += Spell.Tier(SpellType.TELEKINESIS); if (a.curmp > a.maxmp) { a.curmp = a.maxmp; } a.GainSpell(SpellType.TELEKINESIS); B.Add("Runes on " + a.Your() + " armor align themselves with the spell. ", a); } } if (a == user && a == player) { B.Add("You throw yourself forward. "); } else { if (line.Count == 1) { B.Add(user.YouVisible("throw") + " " + a.TheName(true) + " into the ceiling. ", user, a); } else { B.Add(user.YouVisible("throw") + " " + a.TheName(true) + ". ", user, a); } } B.DisplayNow(); user.attrs[AttrType.SELF_TK_NO_DAMAGE] = 1; a.attrs[AttrType.TELEKINETICALLY_THROWN] = 1; a.attrs[AttrType.TURN_INTO_CORPSE]++; if (line.Count == 1) { a.TakeDamage(DamageType.NORMAL, DamageClass.PHYSICAL, R.Roll(3, 6), user, "colliding with the ceiling"); a.CollideWith(a.tile()); } else { a.tile().KnockObjectBack(a, line, 12, user); } a.attrs[AttrType.TELEKINETICALLY_THROWN] = 0; user.attrs[AttrType.SELF_TK_NO_DAMAGE] = 0; if (a.curhp <= 0 && a.HasAttr(AttrType.REGENERATES_FROM_DEATH)) { a.attrs[AttrType.TURN_INTO_CORPSE] = 0; a.attrs[AttrType.CORPSE] = 0; a.attrs[AttrType.FROZEN] = 0; a.attrs[AttrType.INVULNERABLE] = 0; a.attrs[AttrType.SHIELDED] = 0; a.attrs[AttrType.BLOCKING] = 0; a.curhp = 1; //this is all pretty hacky - perhaps I should relocate the regenerating corpse through other means. a.TakeDamage(DamageType.NORMAL, DamageClass.NO_TYPE, 500, null); } else { a.CorpseCleanup(); } } else { if (wand) { return(true); } return(false); } } else { bool blast_fungus = false; if (t.type == TileType.BLAST_FUNGUS && !t.Is(FeatureType.GRENADE, FeatureType.WEB, FeatureType.FORASECT_EGG, FeatureType.BONES)) { blast_fungus = true; } if (t.inv != null || blast_fungus) { Item i = t.inv; string itemname = ""; if (blast_fungus) { itemname = "the blast fungus"; } else { itemname = i.TheName(true); if (i.quantity > 1) { itemname = "the " + i.SingularName(); } } string msg = "Throw " + itemname + " in which direction? "; List <Tile> line = null; if (user == player) { TargetInfo info = t.GetTarget(false, 12, 0, false, true, false, msg); if (info != null) { line = info.extended_line; } } else { line = ai_line; } if (line != null) { if (line.Count > 13) { line = line.ToCount(13); //for range 12 } if (cast) { B.Add(user.You("cast") + " telekinesis. ", user); } if (blast_fungus) { B.Add("The blast fungus is pulled from the floor. ", t); B.Add("Its fuse ignites! ", t); t.Toggle(null); i = Item.Create(ConsumableType.BLAST_FUNGUS, t.row, t.col); if (i != null) { i.other_data = 3; i.revealed_by_light = true; Q.Add(new Event(i, 100, EventType.BLAST_FUNGUS)); Screen.AnimateMapCell(t.row, t.col, new colorchar('3', Color.Red), 100); } } if (line.Count == 1) { B.Add(user.YouVisible("throw") + " " + itemname + " into the ceiling. ", user, t); } else { B.Add(user.YouVisible("throw") + " " + itemname + ". ", user, t); } B.DisplayNow(); if (i.quantity > 1) { i.quantity--; bool revealed = i.revealed_by_light; i = new Item(i, -1, -1); i.revealed_by_light = revealed; } else { t.inv = null; Screen.WriteMapChar(t.row, t.col, M.VisibleColorChar(t.row, t.col)); } bool trigger_traps = false; Tile t2 = line.LastBeforeSolidTile(); Actor first = user.FirstActorInLine(line); if (t2 == line.Last() && first == null) { trigger_traps = true; } if (first != null) { t2 = first.tile(); } line = line.ToFirstSolidTileOrActor(); //if(line.Count > 0){ // line.RemoveAt(line.Count - 1); //} if (line.Count > 0) { line.RemoveAt(line.Count - 1); } { Tile first_unseen = null; foreach (Tile tile2 in line) { if (!tile2.seen) { first_unseen = tile2; break; } } if (first_unseen != null) { line = line.To(first_unseen); if (line.Count > 0) { line.RemoveAt(line.Count - 1); } } } if (line.Count > 0) //or > 1 ? { user.AnimateProjectile(line, i.symbol, i.color); } if (first == user) { B.Add(user.You("catch", true) + " it! ", user); if (user.inv.Count < Global.MAX_INVENTORY_SIZE) { user.GetItem(i); } else { user.tile().GetItem(i); } } else { if (first != null) { B.Add("It hits " + first.the_name + ". ", first); } if (i.IsBreakable()) { if (i.quantity > 1) { B.Add(i.TheName(true) + " break! ", t2); } else { B.Add(i.TheName(true) + " breaks! ", t2); } if (i.NameOfItemType() == "orb") { i.Use(null, new List <Tile> { t2 }); } else { i.CheckForMimic(); } } else { t2.GetItem(i); } t2.MakeNoise(2); } if (first != null && first != user && first != player) { first.player_visibility_duration = -1; first.attrs[AttrType.PLAYER_NOTICED]++; } else { if (trigger_traps && t2.IsTrap()) { t2.TriggerTrap(); } } } else { if (wand) { return(true); } return(false); } } else { if (!t.Is(FeatureType.GRENADE) && (t.Is(TileType.DOOR_C, TileType.DOOR_O, TileType.POISON_BULB) || t.Is(FeatureType.WEB, FeatureType.FORASECT_EGG, FeatureType.BONES))) { if (cast) { B.Add(user.You("cast") + " telekinesis. ", user); } if (t.Is(TileType.DOOR_C)) { B.Add("The door slams open. ", t); t.Toggle(null); } else { if (t.Is(TileType.DOOR_O)) { B.Add("The door slams open. ", t); t.Toggle(null); } } if (t.Is(TileType.POISON_BULB)) { t.Bump(0); } if (t.Is(FeatureType.WEB)) { B.Add("The web is destroyed. ", t); t.RemoveFeature(FeatureType.WEB); } if (t.Is(FeatureType.FORASECT_EGG)) { B.Add("The egg is destroyed. ", t); t.RemoveFeature(FeatureType.FORASECT_EGG); //todo: forasect pathing? } if (t.Is(FeatureType.BONES)) { B.Add("The bones are scattered. ", t); t.RemoveFeature(FeatureType.BONES); } } else { bool grenade = t.Is(FeatureType.GRENADE); bool barrel = t.Is(TileType.BARREL); bool flaming_barrel = barrel && t.IsBurning(); bool torch = t.Is(TileType.STANDING_TORCH); string feature_name = ""; int impact_damage_dice = 3; colorchar vis = new colorchar(t.symbol, t.color); switch (t.type) { case TileType.CRACKED_WALL: feature_name = "cracked wall"; break; case TileType.RUBBLE: feature_name = "pile of rubble"; break; case TileType.STATUE: feature_name = "statue"; break; } if (grenade) { impact_damage_dice = 0; feature_name = "grenade"; vis.c = ','; vis.color = Color.Red; } if (flaming_barrel) { feature_name = "flaming barrel of oil"; } if (barrel) { feature_name = "barrel"; } if (torch) { feature_name = "torch"; } if (feature_name == "") { if (wand) { if (user == player) { B.Add("The wand grabs at empty space. ", t); } return(true); } return(false); } string msg = "Throw the " + feature_name + " in which direction? "; bool passable_hack = !t.passable; if (passable_hack) { t.passable = true; } List <Tile> line = null; if (user == player) { TargetInfo info = t.GetTarget(false, 12, 0, false, true, false, msg); if (info != null) { line = info.extended_line; } } else { line = ai_line; } if (passable_hack) { t.passable = false; } if (line != null) { if (cast) { B.Add(user.You("cast") + " telekinesis. ", user); } if (line.Count == 1) { B.Add(user.YouVisible("throw") + " the " + feature_name + " into the ceiling. ", user, t); } else { B.Add(user.YouVisible("throw") + " the " + feature_name + ". ", user, t); } B.DisplayNow(); user.attrs[AttrType.SELF_TK_NO_DAMAGE] = 1; switch (t.type) { case TileType.CRACKED_WALL: case TileType.RUBBLE: case TileType.STATUE: case TileType.BARREL: case TileType.STANDING_TORCH: if (flaming_barrel) { t.RemoveFeature(FeatureType.FIRE); } t.Toggle(null, TileType.FLOOR); foreach (Tile neighbor in t.TilesAtDistance(1)) { neighbor.solid_rock = false; } break; } if (grenade) { t.RemoveFeature(FeatureType.GRENADE); Event e = Q.FindTargetedEvent(t, EventType.GRENADE); if (e != null) { e.dead = true; } } Screen.WriteMapChar(t.row, t.col, M.VisibleColorChar(t.row, t.col)); colorchar[,] mem = Screen.GetCurrentMap(); int current_row = t.row; int current_col = t.col; // int knockback_strength = 12; if (line.Count == 1) { knockback_strength = 0; } int i = 0; while (true) { Tile t2 = line[i]; if (t2 == t) { break; } ++i; } line.RemoveRange(0, i + 1); while (knockback_strength > 0) //if the knockback strength is greater than 1, you're passing *over* at least one tile. { Tile t2 = line[0]; line.RemoveAt(0); if (!t2.passable) { if (t2.Is(TileType.CRACKED_WALL, TileType.DOOR_C, TileType.HIDDEN_DOOR) && impact_damage_dice > 0) { string tilename = t2.TheName(true); if (t2.type == TileType.HIDDEN_DOOR) { tilename = "a hidden door"; t2.Toggle(null); } B.Add("The " + feature_name + " flies into " + tilename + ". ", t2); t2.Toggle(null); Screen.WriteMapChar(current_row, current_col, mem[current_row, current_col]); } else { B.Add("The " + feature_name + " flies into " + t2.TheName(true) + ". ", t2); if (impact_damage_dice > 0) { t2.Bump(M.tile[current_row, current_col].DirectionOf(t2)); } Screen.WriteMapChar(current_row, current_col, mem[current_row, current_col]); } knockback_strength = 0; break; } else { if (t2.actor() != null) { B.Add("The " + feature_name + " flies into " + t2.actor().TheName(true) + ". ", t2); if (t2.actor().type != ActorType.SPORE_POD && !t2.actor().HasAttr(AttrType.SELF_TK_NO_DAMAGE)) { t2.actor().TakeDamage(DamageType.NORMAL, DamageClass.PHYSICAL, R.Roll(impact_damage_dice, 6), user, "colliding with a " + feature_name); } knockback_strength = 0; Screen.WriteMapChar(t2.row, t2.col, vis); Screen.WriteMapChar(current_row, current_col, mem[current_row, current_col]); current_row = t2.row; current_col = t2.col; break; } else { if (t2.Is(FeatureType.WEB)) //unless perhaps grenades should get stuck and explode in the web? { t2.RemoveFeature(FeatureType.WEB); } Screen.WriteMapChar(t2.row, t2.col, vis); Screen.WriteMapChar(current_row, current_col, mem[current_row, current_col]); current_row = t2.row; current_col = t2.col; Game.GLUpdate(); Thread.Sleep(20); } } //M.Draw(); knockback_strength--; } Tile current = M.tile[current_row, current_col]; if (grenade) { B.Add("The grenade explodes! ", current); current.ApplyExplosion(1, user, "an exploding grenade"); } if (barrel) { B.Add("The barrel smashes! ", current); List <Tile> cone = current.TilesWithinDistance(1).Where(x => x.passable); List <Tile> added = new List <Tile>(); foreach (Tile t3 in cone) { foreach (int dir in U.FourDirections) { if (R.CoinFlip() && t3.TileInDirection(dir).passable) { added.AddUnique(t3.TileInDirection(dir)); } } } cone.AddRange(added); foreach (Tile t3 in cone) { t3.AddFeature(FeatureType.OIL); if (t3.actor() != null && !t3.actor().HasAttr(AttrType.OIL_COVERED, AttrType.SLIMED)) { if (t3.actor().IsBurning()) { t3.actor().ApplyBurning(); } else { t3.actor().attrs[AttrType.OIL_COVERED] = 1; B.Add(t3.actor().YouAre() + " covered in oil. ", t3.actor()); if (t3.actor() == player) { Help.TutorialTip(TutorialTopic.Oiled); } } } } if (flaming_barrel) { current.ApplyEffect(DamageType.FIRE); } } if (torch) { current.AddFeature(FeatureType.FIRE); } user.attrs[AttrType.SELF_TK_NO_DAMAGE] = 0; } else { if (wand) { return(true); } return(false); } } } } } else { return(false); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="FeatureSet"/> class. /// This creates a new featureset by checking each row of the table. If the WKB feature /// type matches the specified featureTypes, then it will copy that. /// </summary> /// <param name="wkbTable"> /// </param> /// <param name="wkbColumnIndex"> /// </param> /// <param name="indexed"> /// </param> /// <param name="type"> /// </param> public FeatureSet(DataTable wkbTable, int wkbColumnIndex, bool indexed, FeatureType type) : this() { if (IndexMode) { // Assume this DataTable has WKB in column[0] and the rest of the columns are attributes. FeatureSetPack result = new FeatureSetPack(); foreach (DataRow row in wkbTable.Rows) { byte[] data = (byte[])row[0]; MemoryStream ms = new MemoryStream(data); WkbFeatureReader.ReadFeature(ms, result); } // convert lists of arrays into a single vertex array for each shape type. result.StopEditing(); // Make sure all the same columns exist in the same order result.Polygons.CopyTableSchema(wkbTable); // Assume that all the features happened to be polygons foreach (DataRow row in wkbTable.Rows) { // Create a new row DataRow dest = result.Polygons.DataTable.NewRow(); dest.ItemArray = row.ItemArray; } } }
/// <summary> /// Initializes a new instance of the <see cref="SpatiaLiteFeatureSet"/> class. /// </summary> /// <param name="fType">The feature type of the contained features.</param> public SpatiaLiteFeatureSet(FeatureType fType) : base(fType) { }
static void CreateFromStyle(XmlTextWriter xtw, Style style, FeatureType featureType) { if (string.IsNullOrEmpty(style.Id)) return; xtw.WriteStartElement("Style"); xtw.WriteAttributeString("id", style.Id); if (featureType == FeatureType.Polygon) { xtw.WriteStartElement("PolyStyle"); xtw.WriteElementString("color", (style.FillStyle == FillStyle.None ? "00ffffff" : ConvertToKmlColor(style.FillColor))); xtw.WriteEndElement(); // PolyStyle } if (featureType == FeatureType.Polyline || featureType == FeatureType.Polygon) { xtw.WriteStartElement("LineStyle"); xtw.WriteElementString("width", (style.LineStyle == LineStyle.None ? 0 : style.LineWidth).ToString(CultureInfo.InvariantCulture)); xtw.WriteElementString("color", ConvertToKmlColor(style.LineColor)); xtw.WriteEndElement(); // LineStyle } else if (featureType == FeatureType.Point) { xtw.WriteStartElement("IconStyle"); if (style.PointSymbol == PointSymbolType.Image) { xtw.WriteStartElement("Icon"); xtw.WriteElementString("href", style.PointSymbolImagePath); xtw.WriteEndElement(); // Icon } else if (style.PointSymbol == PointSymbolType.Shape) { xtw.WriteElementString("color", ConvertToKmlColor(style.LineColor)); } xtw.WriteEndElement(); // IconStyle } xtw.WriteEndElement(); // Style }
/// <summary> /// Creates a new instance of PartRange. /// </summary> /// <param name="allVertices">An array of all the vertex locations</param> /// <param name="shapeOffset">The point index of the shape. </param> /// <param name="partOffset">The ponit index of the part.</param> /// <param name="featureType">The type of features.</param> public PartRange(double[] allVertices, int shapeOffset, int partOffset, FeatureType featureType) : base(allVertices, shapeOffset, partOffset) { _segments = new SegmentRange(this, featureType); }
static extern int btSoftBody_rayTest2(IntPtr obj, [In] ref Vector3 rayFrom, [In] ref Vector3 rayTo, ref float mint, out FeatureType feature, out int index, bool bcountonly);
public bool HasLimitLevel(LimitType limitType, FeatureType featureType, CycleType cycleType, LevelType levelType) => !(GetLimitLevel(limitType, featureType, cycleType, levelType) is null);
/// <summary> /// Constructor with xml parsing /// </summary> /// <param name="mappedFeatureElement">xml</param> /// <param name="featureType">featureType</param> public WfsFeature(XElement mappedFeatureElement, FeatureType featureType) { _featureType = featureType; Update(mappedFeatureElement); }
public EnableFeatureInfoRec GetFeatureInfo(DBManager dbManager, FeatureType type) { return GetFeatureInfo(dbManager, type, null); }
/// <summary> /// Creates a feature from a geometry /// </summary> /// <param name="geometry">The geometry to turn into a feature</param> public Feature(IGeometry geometry) { _basicGeometry = geometry; _featureType = FeatureTypeFromGeometryType(geometry); _dataRow = null; }
protected internal Feature(Layer layer, int featureId) { this.Id = featureId; this.Layer = layer; this.Handle = MiApi.mitab_c_read_feature(layer.Handle, featureId); this.Type = MiApi.mitab_c_get_type(Handle); this.Parts = CreateParts(this); }
private void ReadPolygonShape(Shape shape) { List <ILinearRing> shells = new List <ILinearRing>(); List <ILinearRing> holes = new List <ILinearRing>(); foreach (PartRange part in shape.Range.Parts) { List <Coordinate> coords = new List <Coordinate>(); int i = part.StartIndex; foreach (Vertex d in part) { Coordinate c = new Coordinate(d.X, d.Y); if (shape.M != null && shape.M.Length > 0) { c.M = shape.M[i]; } if (shape.Z != null && shape.Z.Length > 0) { c.Z = shape.Z[i]; } i++; coords.Add(c); } LinearRing ring = new LinearRing(coords.ToArray()); if (shape.Range.Parts.Count == 1) { shells.Add(ring); } else { if (CGAlgorithms.IsCCW(ring.Coordinates)) { holes.Add(ring); } else { shells.Add(ring); } } } if (shells.Count == 0 && holes.Count > 0) { shells = holes; holes = new List <ILinearRing>(); } //// Now we have a list of all shells and all holes List <ILinearRing>[] holesForShells = new List <ILinearRing> [shells.Count]; for (int i = 0; i < shells.Count; i++) { holesForShells[i] = new List <ILinearRing>(); } // Find holes for (int i = 0; i < holes.Count; i++) { ILinearRing testRing = holes[i]; ILinearRing minShell = null; Envelope minEnv = null; Envelope testEnv = testRing.EnvelopeInternal; Coordinate testPt = testRing.Coordinates[0]; for (int j = 0; j < shells.Count; j++) { ILinearRing tryRing = shells[j]; Envelope tryEnv = tryRing.EnvelopeInternal; if (minShell != null) { minEnv = minShell.EnvelopeInternal; } // Check if this new containing ring is smaller than the current minimum ring if (tryEnv.Contains(testEnv) && (CGAlgorithms.IsPointInRing(testPt, tryRing.Coordinates) || (PointInList(testPt, tryRing.Coordinates)))) { if (minShell == null || minEnv.Contains(tryEnv)) { minShell = tryRing; } holesForShells[j].Add(holes[i]); } } } var polygons = new IPolygon[shells.Count]; for (int i = 0; i < shells.Count; i++) { polygons[i] = new Polygon(shells[i], holesForShells[i].ToArray()); } if (polygons.Length == 1) { _basicGeometry = polygons[0]; } else { // It's a multi part _basicGeometry = new MultiPolygon(polygons); } _featureType = FeatureType.Polygon; }
/// <summary> /// Creates a new shapefile that has a specific feature type /// </summary> /// <param name="featureType"></param> protected Shapefile(FeatureType featureType) : base(featureType) { }
/// <summary> /// Creates a feature from the specified shape. This will not handle the attribute content, /// which should be handles separately, with full knowledge of the desired schema. /// </summary> /// <param name="shape">The shape to read the vertices from in order to build a proper geometry.</param> public Feature(Shape shape) { if (shape.Range == null) { return; } ShapeIndex = shape.Range; if (shape.Range.FeatureType == FeatureType.Point) { Coordinate c = new Coordinate(shape.Vertices[0], shape.Vertices[1]); if (shape.Z != null) { c.Z = shape.Z[0]; } if (shape.M != null) { c.M = shape.M[0]; } _basicGeometry = new Point(c); _featureType = FeatureType.Point; } if (shape.Range.FeatureType == FeatureType.MultiPoint) { List <Coordinate> coords = new List <Coordinate>(); foreach (PartRange part in shape.Range.Parts) { for (int i = part.StartIndex; i <= part.EndIndex; i++) { Coordinate c = new Coordinate(shape.Vertices[i * 2], shape.Vertices[i * 2 + 1]); if (shape.Z != null) { c.Z = shape.Z[i]; } if (shape.M != null) { c.M = shape.M[i]; } coords.Add(c); } } _basicGeometry = new MultiPoint(coords.CastToPointArray()); _featureType = FeatureType.MultiPoint; } if (shape.Range.FeatureType == FeatureType.Line) { List <ILineString> strings = new List <ILineString>(); foreach (PartRange part in shape.Range.Parts) { List <Coordinate> coords = new List <Coordinate>(); for (int i = part.StartIndex; i <= part.EndIndex; i++) { Coordinate c = new Coordinate(shape.Vertices[i * 2], shape.Vertices[i * 2 + 1]); if (shape.Z != null) { c.Z = shape.Z[i]; } if (shape.M != null) { c.M = shape.M[i]; } coords.Add(c); } strings.Add(new LineString(coords.ToArray())); } if (strings.Count > 1) { _basicGeometry = new MultiLineString(strings.ToArray()); } else if (strings.Count == 1) { _basicGeometry = strings[0]; } _featureType = FeatureType.Line; } if (shape.Range.FeatureType == FeatureType.Polygon) { ReadPolygonShape(shape); } }
/// <summary> /// Initializes a new instance of the <see cref="FeatureSet"/> class. /// Creates a new FeatureSet /// </summary> /// <param name="featureType"> /// The Feature type like point, line or polygon /// </param> public FeatureSet(FeatureType featureType) : this() { FeatureType = featureType; }
public ClusteringForm_old(FeatureType dataType) { this.dataType = dataType; InitializeComponent(); }
internal static void FillLines(string fileName, IProgressHandler progressHandler, Shapefile shapefile, FeatureType featureType) { // Check to ensure the fileName is not null if (fileName == null) { throw new NullReferenceException(DataStrings.ArgumentNull_S.Replace("%S", "fileName")); } if (shapefile == null) throw new ArgumentNullException("shapefile"); if (File.Exists(fileName) == false) { throw new FileNotFoundException(DataStrings.FileNotFound_S.Replace("%S", fileName)); } if (featureType != FeatureType.Line && featureType != FeatureType.Polygon) { throw new NotSupportedException(); } var header = shapefile.Header; // Check to ensure that the fileName is the correct shape type switch (featureType) { case FeatureType.Line: if (header.ShapeType != ShapeType.PolyLine && header.ShapeType != ShapeType.PolyLineM && header.ShapeType != ShapeType.PolyLineZ) { throw new ArgumentException(DataStrings.FileNotLines_S.Replace("%S", fileName)); } break; case FeatureType.Polygon: if (header.ShapeType != ShapeType.Polygon && header.ShapeType != ShapeType.PolygonM && header.ShapeType != ShapeType.PolygonZ) { throw new ArgumentException(DataStrings.FileNotLines_S.Replace("%S", fileName)); } break; } if (new FileInfo(fileName).Length == 100) { // the file is empty so we are done reading return; } // Reading the headers gives us an easier way to track the number of shapes and their overall length etc. var shapeHeaders = shapefile.ReadIndexFile(fileName); int numShapes = shapeHeaders.Count; bool isM = false, isZ = false; switch (header.ShapeType) { case ShapeType.PolyLineM: case ShapeType.PolygonM: isM = true; break; case ShapeType.PolyLineZ: case ShapeType.PolygonZ: isZ = true; isM = true; break; } int totalPointsCount = 0; int totalPartsCount = 0; var shapeIndices = new List<ShapeRange>(numShapes); var progressMeter = new ProgressMeter(progressHandler, "Reading from " + Path.GetFileName(fileName)) { StepPercent = 5 }; using (var reader = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, 65536)) { var boundsBytes = new byte[4 * 8]; var bounds = new double[4]; for (int shp = 0; shp < numShapes; shp++) { progressMeter.CurrentPercent = (int)(shp * 50.0 / numShapes); // Read from the index file because some deleted records // might still exist in the .shp file. long offset = (shapeHeaders[shp].ByteOffset); reader.Seek(offset, SeekOrigin.Begin); var shape = new ShapeRange(featureType, shapefile.CoordinateType) { RecordNumber = reader.ReadInt32(Endian.BigEndian), ContentLength = reader.ReadInt32(Endian.BigEndian), ShapeType = (ShapeType)reader.ReadInt32(), StartIndex = totalPointsCount }; Debug.Assert(shape.RecordNumber == shp + 1); if (shape.ShapeType != ShapeType.NullShape) { // Bounds reader.Read(boundsBytes, 0, boundsBytes.Length); Buffer.BlockCopy(boundsBytes, 0, bounds, 0, boundsBytes.Length); shape.Extent.MinX = bounds[0]; shape.Extent.MinY = bounds[1]; shape.Extent.MaxX = bounds[2]; shape.Extent.MaxY = bounds[3]; // Num Parts shape.NumParts = reader.ReadInt32(); totalPartsCount += shape.NumParts; // Num Points shape.NumPoints = reader.ReadInt32(); totalPointsCount += shape.NumPoints; } shapeIndices.Add(shape); } var vert = new double[totalPointsCount * 2]; var vertInd = 0; var parts = new int[totalPartsCount]; var partsInd = 0; double[] mArray = null, zArray = null; if (isM) { mArray = new double[totalPointsCount]; } int mArrayInd = 0; if (isZ) { zArray = new double[totalPointsCount]; } int zArrayInd = 0; int partsOffset = 0; for (int shp = 0; shp < numShapes; shp++) { progressMeter.CurrentPercent = (int)(50 + shp * 50.0 / numShapes); var shape = shapeIndices[shp]; if (shape.ShapeType == ShapeType.NullShape) continue; reader.Seek(shapeHeaders[shp].ByteOffset, SeekOrigin.Begin); reader.Seek(3 * 4 + 32 + 2 * 4, SeekOrigin.Current); // Skip first bytes // Read parts var partsBytes = reader.ReadBytes(4 * shape.NumParts); Buffer.BlockCopy(partsBytes, 0, parts, partsInd, partsBytes.Length); partsInd += 4 * shape.NumParts; // Read points var pointsBytes = reader.ReadBytes(8 * 2 * shape.NumPoints); Buffer.BlockCopy(pointsBytes, 0, vert, vertInd, pointsBytes.Length); vertInd += 8 * 2 * shape.NumPoints; // Fill parts shape.Parts.Capacity = shape.NumParts; for (int part = 0; part < shape.NumParts; part++) { int endIndex = shape.NumPoints + shape.StartIndex; int startIndex = parts[partsOffset + part] + shape.StartIndex; if (part < shape.NumParts - 1) { endIndex = parts[partsOffset + part + 1] + shape.StartIndex; } int count = endIndex - startIndex; var partR = new PartRange(vert, shape.StartIndex, parts[partsOffset + part], featureType) { NumVertices = count }; shape.Parts.Add(partR); } partsOffset += shape.NumParts; // Fill M and Z arrays switch (header.ShapeType) { case ShapeType.PolyLineM: case ShapeType.PolygonM: if (shape.ContentLength * 2 > 44 + 4 * shape.NumParts + 16 * shape.NumPoints) { var mExt = (IExtentM)shape.Extent; mExt.MinM = reader.ReadDouble(); mExt.MaxM = reader.ReadDouble(); var mBytes = reader.ReadBytes(8 * shape.NumPoints); Buffer.BlockCopy(mBytes, 0, mArray, mArrayInd, mBytes.Length); mArrayInd += 8 * shape.NumPoints; } break; case ShapeType.PolyLineZ: case ShapeType.PolygonZ: var zExt = (IExtentZ)shape.Extent; zExt.MinZ = reader.ReadDouble(); zExt.MaxZ = reader.ReadDouble(); var zBytes = reader.ReadBytes(8 * shape.NumPoints); Buffer.BlockCopy(zBytes, 0, zArray, zArrayInd, zBytes.Length); zArrayInd += 8 * shape.NumPoints; // These are listed as "optional" but there isn't a good indicator of how to // determine if they were added. // To handle the "optional" M values, check the contentLength for the feature. // The content length does not include the 8-byte record header and is listed in 16-bit words. if (shape.ContentLength * 2 > 60 + 4 * shape.NumParts + 24 * shape.NumPoints) { goto case ShapeType.PolyLineM; } break; } } if (isM) shapefile.M = mArray; if (isZ) shapefile.Z = zArray; shapefile.ShapeIndices = shapeIndices; shapefile.Vertex = vert; } progressMeter.Reset(); }
// This draws the individual point features private void DrawFeatures(MapArgs e, IEnumerable <int> indices) { Graphics g = e.Device ?? Graphics.FromImage(BackBuffer); Matrix origTransform = g.Transform; FeatureType featureType = DataSet.FeatureType; if (!DrawnStatesNeeded) { if (Symbology == null || Symbology.Categories.Count == 0) { return; } FastDrawnState state = new FastDrawnState(false, Symbology.Categories[0]); IPointCategory pc = state.Category as IPointCategory; if (pc == null) { return; } IPointSymbolizer ps = pc.Symbolizer; if (ps == null) { return; } double[] vertices = DataSet.Vertex; foreach (int index in indices) { if (DrawnStates != null && DrawnStates.Length > index && !DrawnStates[index].Visible) { continue; } if (featureType == FeatureType.Point) { DrawPoint(vertices[index * 2], vertices[index * 2 + 1], e, ps, g, origTransform); } else { // multi-point ShapeRange range = DataSet.ShapeIndices[index]; for (int i = range.StartIndex; i <= range.EndIndex(); i++) { DrawPoint(vertices[i * 2], vertices[i * 2 + 1], e, ps, g, origTransform); } } } } else { FastDrawnState[] states = DrawnStates; double[] vertices = DataSet.Vertex; foreach (int index in indices) { if (index >= states.Length) { break; } FastDrawnState state = states[index]; if (!state.Visible || state.Category == null) { continue; } IPointCategory pc = state.Category as IPointCategory; if (pc == null) { continue; } IPointSymbolizer ps = state.Selected ? pc.SelectionSymbolizer : pc.Symbolizer; if (ps == null) { continue; } if (featureType == FeatureType.Point) { DrawPoint(vertices[index * 2], vertices[index * 2 + 1], e, ps, g, origTransform); } else { ShapeRange range = DataSet.ShapeIndices[index]; for (int i = range.StartIndex; i <= range.EndIndex(); i++) { DrawPoint(vertices[i * 2], vertices[i * 2 + 1], e, ps, g, origTransform); } } } } if (e.Device == null) { g.Dispose(); } else { g.Transform = origTransform; } }
public int RayTest(Vector3 rayFrom, Vector3 rayTo, ref float mint, out FeatureType feature, out int index, bool countOnly) { return btSoftBody_rayTest2(_native, ref rayFrom, ref rayTo, ref mint, out feature, out index, countOnly); }
public void SaveFeatureToShapefileWithMandZ(CoordinateType c, FeatureType ft) { var fileName = FileTools.GetTempFileName(".shp"); try { List <Coordinate> coords = new() { new CoordinateZM(1, 2, 7, 4), new CoordinateZM(3, 4, 5, 6), new CoordinateZM(5, 6, 3, 8), new CoordinateZM(7, 8, 9, 10), new CoordinateZM(1, 2, 7, 4) }; var fs = new FeatureSet(ft) { Projection = KnownCoordinateSystems.Geographic.World.WGS1984, CoordinateType = c }; switch (ft) { case FeatureType.Line: fs.AddFeature(new LineString(coords.ToArray())); break; case FeatureType.Polygon: fs.AddFeature(new Polygon(new LinearRing(coords.ToArray()))); break; case FeatureType.MultiPoint: coords.RemoveAt(4); fs.AddFeature(new MultiPoint(coords.CastToPointArray())); break; } Assert.DoesNotThrow(() => fs.SaveAs(fileName, true)); var loaded = FeatureSet.Open(fileName); if (c == CoordinateType.Regular) { Assert.IsTrue(loaded.Features[0].Geometry.Coordinates[0] is Coordinate); Assert.IsFalse(loaded.Features[0].Geometry.Coordinates[0] is CoordinateZ); Assert.IsFalse(loaded.Features[0].Geometry.Coordinates[0] is CoordinateM); } else if (c == CoordinateType.M) { Assert.IsTrue(loaded.Features[0].Geometry.Coordinates[0] is CoordinateM); Assert.IsFalse(loaded.Features[0].Geometry.Coordinates[0] is CoordinateZ); if (loaded.Features[0].Geometry.Coordinates[0] is CoordinateM cm) { Assert.AreEqual(4, cm.M); Assert.AreEqual(4, loaded.Features[0].Geometry.MinM()); Assert.AreEqual(10, loaded.Features[0].Geometry.MaxM()); } } else if (c == CoordinateType.Z) { Assert.IsTrue(loaded.Features[0].Geometry.Coordinates[0] is CoordinateZM); if (loaded.Features[0].Geometry.Coordinates[0] is CoordinateZM cm) { Assert.AreEqual(7, cm.Z); Assert.AreEqual(3, loaded.Features[0].Geometry.MinZ()); Assert.AreEqual(9, loaded.Features[0].Geometry.MaxZ()); Assert.AreEqual(4, cm.M); Assert.AreEqual(4, loaded.Features[0].Geometry.MinM()); Assert.AreEqual(10, loaded.Features[0].Geometry.MaxM()); } } } finally { FileTools.DeleteShapeFile(fileName); } }
protected AnnotationBasedFacetFactoryAbstract(int numericOrder, FeatureType featureTypes) : base(numericOrder, featureTypes) {}
/// <summary> /// Loads the shapes from the given file into the given shapefile. /// </summary> /// <param name="fileName">Name of the file whose shapes should get loaded.</param> /// <param name="progressHandler">ProgressHandler that shows the progress.</param> /// <param name="shapefile">Shapefile the shapes are loaded into.</param> /// <param name="featureType">FeatureType that should be inside the file.</param> /// <exception cref="ArgumentNullException">Throws an ArgumentNullException, if the shapefile is null.</exception> /// <exception cref="ArgumentException">Throws an ArgumentException, if the FeatureType is Line but the files doesn't contain lines or the FeatureType is Polygon and the file doesn't contain polygons.</exception> /// <exception cref="NotSupportedException">Throws a NotSupportedException, if a FeatureType other than Line or Polygon is passed.</exception> /// <exception cref="FileNotFoundException">Throws a FileNotFoundException, if the file whith the path from fileName doesn't exist.</exception> /// <exception cref="NullReferenceException">Throws a NullReferenceException, if the fileName is null.</exception> internal static void FillLines(string fileName, IProgressHandler progressHandler, Shapefile shapefile, FeatureType featureType) { // Check to ensure the fileName is not null if (fileName == null) { throw new NullReferenceException(DataStrings.ArgumentNull_S.Replace("%S", "fileName")); } if (shapefile == null) { throw new ArgumentNullException(nameof(shapefile)); } if (!File.Exists(fileName)) { throw new FileNotFoundException(DataStrings.FileNotFound_S.Replace("%S", fileName)); } if (featureType != FeatureType.Line && featureType != FeatureType.Polygon) { throw new NotSupportedException(); } var header = shapefile.Header; // Check to ensure that the fileName is the correct shape type switch (featureType) { case FeatureType.Line: if (header.ShapeType != ShapeType.PolyLine && header.ShapeType != ShapeType.PolyLineM && header.ShapeType != ShapeType.PolyLineZ) { throw new ArgumentException(DataStrings.FileNotLines_S.Replace("%S", fileName)); } break; case FeatureType.Polygon: if (header.ShapeType != ShapeType.Polygon && header.ShapeType != ShapeType.PolygonM && header.ShapeType != ShapeType.PolygonZ) { throw new ArgumentException(DataStrings.FileNotLines_S.Replace("%S", fileName)); } break; } if (new FileInfo(fileName).Length == 100) { // the file is empty so we are done reading return; } // Reading the headers gives us an easier way to track the number of shapes and their overall length etc. var shapeHeaders = shapefile.ReadIndexFile(fileName); int numShapes = shapeHeaders.Count; bool isM = false, isZ = false; switch (header.ShapeType) { case ShapeType.PolyLineM: case ShapeType.PolygonM: isM = true; break; case ShapeType.PolyLineZ: case ShapeType.PolygonZ: isZ = true; isM = true; break; } int totalPointsCount = 0; int totalPartsCount = 0; var shapeIndices = new List <ShapeRange>(numShapes); var progressMeter = new ProgressMeter(progressHandler, "Reading from " + Path.GetFileName(fileName)) { StepPercent = 5 }; using (var reader = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, 65536)) { var boundsBytes = new byte[4 * 8]; var bounds = new double[4]; for (int shp = 0; shp < numShapes; shp++) { progressMeter.CurrentPercent = (int)(shp * 50.0 / numShapes); // Read from the index file because some deleted records // might still exist in the .shp file. long offset = shapeHeaders[shp].ByteOffset; reader.Seek(offset, SeekOrigin.Begin); var shape = new ShapeRange(featureType, shapefile.CoordinateType) { RecordNumber = reader.ReadInt32(Endian.BigEndian), ContentLength = reader.ReadInt32(Endian.BigEndian), ShapeType = (ShapeType)reader.ReadInt32(), StartIndex = totalPointsCount }; Debug.Assert(shape.RecordNumber == shp + 1); if (shape.ShapeType != ShapeType.NullShape) { // Bounds reader.Read(boundsBytes, 0, boundsBytes.Length); Buffer.BlockCopy(boundsBytes, 0, bounds, 0, boundsBytes.Length); shape.Extent.MinX = bounds[0]; shape.Extent.MinY = bounds[1]; shape.Extent.MaxX = bounds[2]; shape.Extent.MaxY = bounds[3]; // Num Parts shape.NumParts = reader.ReadInt32(); totalPartsCount += shape.NumParts; // Num Points shape.NumPoints = reader.ReadInt32(); totalPointsCount += shape.NumPoints; } shapeIndices.Add(shape); } var vert = new double[totalPointsCount * 2]; var vertInd = 0; var parts = new int[totalPartsCount]; var partsInd = 0; double[] mArray = null, zArray = null; if (isM) { mArray = new double[totalPointsCount]; } int mArrayInd = 0; if (isZ) { zArray = new double[totalPointsCount]; } int zArrayInd = 0; int partsOffset = 0; for (int shp = 0; shp < numShapes; shp++) { progressMeter.CurrentPercent = (int)(50 + shp * 50.0 / numShapes); var shape = shapeIndices[shp]; if (shape.ShapeType == ShapeType.NullShape) { continue; } reader.Seek(shapeHeaders[shp].ByteOffset, SeekOrigin.Begin); reader.Seek(3 * 4 + 32 + 2 * 4, SeekOrigin.Current); // Skip first bytes (Record Number, Content Length, Shapetype + BoundingBox + NumParts, NumPoints) // Read parts var partsBytes = reader.ReadBytes(4 * shape.NumParts); //Numparts * Integer(4) = existing Parts Buffer.BlockCopy(partsBytes, 0, parts, partsInd, partsBytes.Length); partsInd += 4 * shape.NumParts; // Read points var pointsBytes = reader.ReadBytes(8 * 2 * shape.NumPoints); //Numpoints * Point (X(8) + Y(8)) Buffer.BlockCopy(pointsBytes, 0, vert, vertInd, pointsBytes.Length); vertInd += 8 * 2 * shape.NumPoints; // Fill parts shape.Parts.Capacity = shape.NumParts; for (int part = 0; part < shape.NumParts; part++) { int endIndex = shape.NumPoints + shape.StartIndex; int startIndex = parts[partsOffset + part] + shape.StartIndex; if (part < shape.NumParts - 1) { endIndex = parts[partsOffset + part + 1] + shape.StartIndex; } int count = endIndex - startIndex; var partR = new PartRange(vert, shape.StartIndex, parts[partsOffset + part], featureType) { NumVertices = count }; shape.Parts.Add(partR); } partsOffset += shape.NumParts; // Fill M and Z arrays switch (header.ShapeType) { case ShapeType.PolyLineM: case ShapeType.PolygonM: if (shape.ContentLength * 2 > 44 + 4 * shape.NumParts + 16 * shape.NumPoints) { var mExt = (IExtentM)shape.Extent; mExt.MinM = reader.ReadDouble(); mExt.MaxM = reader.ReadDouble(); var mBytes = reader.ReadBytes(8 * shape.NumPoints); Buffer.BlockCopy(mBytes, 0, mArray, mArrayInd, mBytes.Length); mArrayInd += 8 * shape.NumPoints; } break; case ShapeType.PolyLineZ: case ShapeType.PolygonZ: var zExt = (IExtentZ)shape.Extent; zExt.MinZ = reader.ReadDouble(); zExt.MaxZ = reader.ReadDouble(); var zBytes = reader.ReadBytes(8 * shape.NumPoints); Buffer.BlockCopy(zBytes, 0, zArray, zArrayInd, zBytes.Length); zArrayInd += 8 * shape.NumPoints; // These are listed as "optional" but there isn't a good indicator of how to determine if they were added. // To handle the "optional" M values, check the contentLength for the feature. // The content length does not include the 8-byte record header and is listed in 16-bit words. if (shape.ContentLength * 2 > 60 + 4 * shape.NumParts + 24 * shape.NumPoints) { goto case ShapeType.PolyLineM; } break; } } if (isM) { shapefile.M = mArray; } if (isZ) { shapefile.Z = zArray; } shapefile.ShapeIndices = shapeIndices; shapefile.Vertex = vert; } progressMeter.Reset(); }
public EventStatus(DeviceBase device, FeatureType featureType, uint featureId, int frequency, ObservableCollection<DeviceEventSettings> emitEvents) { Device = device; FeatureType = featureType; FeatureId = featureId; Frequency = frequency; ToDeviceLinks = new List<DeviceLink>(); FromDeviceLinks = new List<DeviceLink>(); EmitEvents = new List<DeviceEventConfig>(); foreach(DeviceEventSettings es in device.DeviceManagerDeviceSettings.DeviceEvents) if (es.EventFeatureType == FeatureType && es.EventFeatureId == FeatureId) EmitEvents.Add(new DeviceEventConfig(es)); }
public void Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification, FeatureType featureType) { foreach (var facetFactory in GetFactoryByFeatureType(featureType)) { facetFactory.Process(reflector, property, methodRemover, specification); } }
/// <summary> /// Creates a new shapefile that has a specific feature type /// </summary> /// <param name="featureType"></param> protected Shapefile(FeatureType featureType) : this(null, featureType) { }
public IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification, FeatureType featureType, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) => throw new NotImplementedException();
public MapTypeStyleBuilder FeatureType(FeatureType featureType) { Style.FeatureType = featureType; return this; }
private IList <IFacetFactory> GetFactoryByFeatureType(FeatureType featureType) => factoriesByFeatureType[featureType];