public FeatureList GetFeatureList() { if (null == dxf) { throw new Exception("Dxf file has not been set."); } FeatureList fList = new FeatureList(); foreach (var layer in dxf.Layers) { Feature feature = new Feature(); feature.Name = layer.Name; feature.Color = new ColorAsBrush (layer.Color.R , layer.Color.G , layer.Color.B ); feature.FillColor = feature.Color; //feature.Style = layer.LineType; feature.Weight = layer.Lineweight.Value; feature.Printable = layer.Plot; fList.AddFeature(feature); } return(fList); }
public static Case Clone(Case c) { if (c == null) { return(null); } FeatureList list = new FeatureList(); Case instance = CaseFactory.CreateInstance(c.GetCaseID(), c.GetCaseName(), c.GetCaseDescription(), c.GetCaseType(), list); System.Collections.ArrayList features = c.GetFeatures(); foreach (Feature f in features) { c.AddFeature(f.GetFeatureName(), f.GetFeatureType(), f.GetFeatureValue(), f.GetWeight(), f.GetIsKey(), f.GetIsIndex(), f.GetFeatureUnit()); } return(instance); }
/** * Processes a single Feature. * * @param input * Individual Feature to process. * @param env * Runtime processing environment. * @return * A collection of Feature instances. The default implementation * of this method just returns the input in a list. */ public virtual FeatureList process(Feature input, FilterEnv env) { FeatureList output = new FeatureList(); output.Add(input); return(output); }
override public FeatureList process(FeatureList input, FilterEnv env) { foreach (Feature feature in input) { CoordinateSystemFactory csf = new CoordinateSystemFactory(); ICoordinateSystem cssource = csf.CreateFromWkt(((SharpMapSpatialReference)feature.getGeometry().SpatialReference).CoordinateSystem.WKT); ICoordinateSystem cstarget; if (translateScript != null) { //Console.WriteLine(Registry.instance().GetEngine("Python").run(TranslateScript).asString()); cstarget = csf.CreateFromWkt(Registry.instance().GetEngine("Python").run(TranslateScript).asString()); } else { cstarget = csf.CreateFromWkt(env.getInputSRS().WKT); } CoordinateTransformationFactory ctf = new CoordinateTransformationFactory(); ICoordinateTransformation ct = ctf.CreateFromCoordinateSystems(cssource, cstarget); //if (feature.getGeometry().GeometryType == GeometryType2.Point) //{ // Point p = (Point)feature.getGeometry(); //GeometryTransform.TransformPoint(feature, ct.MathTransform); Geometry geom = feature.getGeometry(); Geometry geomRst = GeometryTransform.TransformGeometry(geom, ct.MathTransform); feature.setGeometry(geomRst); //} } return(input); }
/// <summary> /// Update the list of feature entitlements for a particular user. /// </summary> /// <param name="uid">User ID.</param> /// <param name="features">List of features.</param> /// <returns>Success response.</returns> public SuccessResponse UpdateFeatures(long uid, List <Feature> features) { var payload = new FeatureList(); payload.AddRange(features); return(_apiExecutor.Execute(_userApi.V1AdminUserUidFeaturesUpdatePost, _authTokens.SessionToken, (long?)uid, payload)); }
public Case(int caseID, string caseName, string caseDescription) { _caseID = caseID; _caseName = caseName; _caseDescription = caseDescription; _featureList = new FeatureList(); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); bool isAccessAllowed = false; FeatureValue feature; PermissionValue permission; for (int i = 0; i < FeatureList.Count(); i++) { feature = FeatureList[i]; permission = PermissionList[i]; isAccessAllowed = UserPermission.VerifyPermission(feature, permission, Convert.ToInt16(ExcludeParamId)); if (isAccessAllowed) { break; } } if (!isAccessAllowed) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { action = "UnauthorizedAccess", controller = "Security" })); } }
/// <summary> /// Don't actually open the shapefile in this case, just initialize the /// major variables. /// </summary> public ShapefileFeatureSet() { //Fields = new Dictionary<string, Field>(); _columns = new List<Field>(); DataTable = new System.Data.DataTable(); Features = new FeatureList(this); FeatureType = FeatureTypes.Unspecified; }
public void FeatureList_Adding3Features_yields4Count() { FeatureList fl = new FeatureList(); add3Features(fl); Assert.AreEqual(expected: 4, actual: fl.Children.Count); }
public override FeatureList process(Feature input, FilterEnv env) { FeatureList output = new FeatureList(); if (transform != null && !transform.Identity()) { foreach (GeoShape shape in input.getShapes()) { XformVisitor visitor = new XformVisitor(); visitor.trans = transform; shape.accept(visitor); } } output.Add(input); return(output); #if TODO // resolve the xlate shortcut Matrix working_matrix = xform_matrix; // TODO: this can go into process(FeatureList) instead of running for every feature.. if (getTranslateScript() != null) { ScriptResult r = env.getScriptEngine().run(getTranslateScript(), input, env); if (r.isValid()) { working_matrix = Matrix.translate(r.asVec3()); } else { env.getReport().error(r.asString()); } } if (working_srs != null || (working_matrix != null && !working_matrix.IsIdentity)) { foreach (GeoShape shape in input.getShapes()) { if (working_matrix != null && !working_matrix.IsIdentity) { XformVisitor visitor; visitor.mat = working_matrix; shape.accept(visitor); } if (working_srs != null && !working_srs.equivalentTo(env.getInputSRS())) { working_srs.transformInPlace(shape); } } } output.Add(input); return(output); #endif throw new NotImplementedException(); }
public void FeatureList_NewHasDefaultFeature() { FeatureList fl = new FeatureList(); Assert.AreEqual(expected: 1, actual: fl.Children.Count); Assert.AreEqual(expected: "Default", actual: fl.Children["Default"].Name); }
public static Case CreateInstance(int caseID, string caseName, string caseDescription, int caseType, FeatureList featureList) { Case instance = new Case(caseID, caseName, caseDescription, featureList, caseType); instances++; return(instance); }
public Model() { WorldMouse = new Models.WorldMouse(); BoundingBox = new BoundingBox(); allViewPorts = new Dictionary <String, CadViewPort>(); allGrahics = new List <Graphic>(); NotificationTarget = null; FeatureList = new FeatureList(); }
/** * Processes a batch of Feature objects. * * @param input * Batch of features to process. * @param env * Runtime processing environment. * @return * A collection of Feature instances. The default implementation * of this method just returns the input. */ public virtual FeatureList process(FeatureList input, FilterEnv env) { FeatureList output = new FeatureList(); foreach (Feature i in input) { FeatureList interim = process(i, env); output.InsertRange(output.Count, interim); } return output; }
// FragmentFilter overrides protected virtual FragmentList process(FeatureList input, FilterEnv env) { // load and cache the font if (!string.IsNullOrEmpty(getFontName()) && !font.valid()) { font = osgText.readFontFile(getFontName()); } return(base.process(input, env)); }
public void push(FeatureList input) { foreach (Feature i in input) { if (i.hasShapeData()) { in_features.Add(i); } } }
public override FeatureList process(FeatureList input, FilterEnv env) { FeatureList output = new FeatureList(); //Boolean encontrado = false; SharpMap.Geometries.BoundingBox boundingBox = new SharpMap.Geometries.BoundingBox(longitudeMin, latitudeMin, longitudeMax, latitudeMax); foreach (Feature feature in input) { //if type of features is Point if (feature.row.Geometry is SharpMap.Geometries.Point) { SharpMap.Geometries.Point p = (SharpMap.Geometries.Point)feature.row.Geometry; if (boundingBox.Contains(p.GetBoundingBox())) { output.Add(feature); } } //if type of features is Polygon else if (feature.row.Geometry is SharpMap.Geometries.Polygon) { SharpMap.Geometries.Polygon polygon = (SharpMap.Geometries.Polygon)feature.row.Geometry; if (boundingBox.Contains(polygon.GetBoundingBox())) { output.Add(feature); } } //if type of features is MultiPolygon else if (feature.row.Geometry is SharpMap.Geometries.MultiPolygon) { SharpMap.Geometries.MultiPolygon mp = (SharpMap.Geometries.MultiPolygon)feature.row.Geometry; SharpMap.Geometries.BoundingBox bb = mp.GetBoundingBox(); if (boundingBox.Contains(bb)) { output.Add(feature); } } } if (successor != null) { if (successor is FeatureFilter) { FeatureFilter filter = (FeatureFilter)successor; FeatureList l = filter.process(output, env); } else if (successor is FragmentFilter) { FragmentFilter filter = (FragmentFilter)successor; FragmentList l = filter.process(output, env); } } return(output); }
protected void PCs_TextChanged(object sender, EventArgs e) { if (int.Parse(PCs.Text) > FeatureList.GetSelectedIndices().Count()) { Warning.Text = "Cannot extract more principal components than selected features"; } else { Warning.Text = ""; } }
/** * Processes a collection of features into a collection of nodes. * * @param input * Batch of features to process * @param env * Contextual compilation environment * @return * Resulting node list */ public virtual AttributedNodeList process(FeatureList input, FilterEnv env) { AttributedNodeList output = new AttributedNodeList(); foreach (Feature i in input) { AttributedNodeList interim = process(i, env); output.InsertRange(output.Count, interim); } return(output); }
/** * Processes a collection of features into fragments. Override this * method in your implementation to convert batches of features into * fragments. * * @param input * Batch of features to convert into drawables * @param env * Contextual compilation information * @return * The converted input data. The default implementation of this * method returns an empty set. */ public virtual FragmentList process(FeatureList input, FilterEnv env) { FragmentList output = new FragmentList(); foreach (Feature i in input) { FragmentList interim = process(i, env); output.InsertRange(output.Count, interim); } return(output); }
public void LoadDXFFile(String fullFileName) { DxfHelperRead readerHelper = new DxfHelperRead(fullFileName); this.FeatureList = readerHelper.GetFeatureList(); var styleList = readerHelper.GetStyleLibrary(); this.allViewPorts = readerHelper.GetViewPorts(); this.allGrahics = readerHelper.GetGraphics(); this.allGrahics.ForEach(element => this.BoundingBox.expandByBox(element.BoundingBox)); }
public FeatureList Convert(ResolutionContext context) { List <FeatureDto> list = context.SourceValue as List <FeatureDto>; FeatureList namedlist = new FeatureList(); foreach (FeatureDto v in list) { namedlist.Add(Mapper.Map <Feature> (v)); } return(namedlist); }
public void Test() { const string settingFilepath = @".\Test\Features.xml"; FeatureList featuresList = FeatureListBuilder.GetFeaturesList(settingFilepath); IEnumerable <FeatureContent> features = featuresList.Features; var notIgnoredFeatures = features.Where(f => !f.Ignore).Select(f => f.FeatureName); var expectedNotInoredFeatures = new List <string> { "idf", "DigitsCount", "SolrQueryDependent" }; Assert.That(notIgnoredFeatures, Is.EquivalentTo(expectedNotInoredFeatures)); }
public static FeatureList DataTableToList(FeatureDataTable table) { FeatureList list = new FeatureList(); foreach (FeatureDataRow row in table) { Feature f = new Feature(); f.setFeature(row); list.Add(f); } return(list); }
public void FeatureList_RemovingExistingMember_Succeeds() { FeatureList fl = new FeatureList(); add3Features(fl); int precount = fl.Children.Count; bool actual = fl.TryRemoveFeature("F2"); Assert.AreEqual(expected: true, actual: actual); Assert.AreEqual(expected: precount - 1, actual: fl.Children.Count); }
public void FeatureList_RemovingNonExistantMember_Fails() { FeatureList fl = new FeatureList(); add3Features(fl); int precount = fl.Children.Count; bool actual = fl.TryRemoveFeature("Doesnt Exist"); Assert.AreEqual(expected: false, actual: actual); Assert.AreEqual(expected: precount, actual: fl.Children.Count); }
private void add3Features(FeatureList aFL) { var f1 = new Feature(); f1.Name = "F1"; aFL.AddFeature(f1); f1 = new Feature(); f1.Name = "F2"; aFL.AddFeature(f1); f1 = new Feature(); f1.Name = "F3"; aFL.AddFeature(f1); }
public override FeatureList process(FeatureList input, FilterEnv env) { FeatureList output = new FeatureList(); foreach (Feature feature in input) { //engine.run(script, feature, null); if (feature.row[attributeName].ToString().ToLowerInvariant() == attributeValue) { output.Add(feature); } } return(output); }
/// <summary> /// 根据ShpReader和DbfReader创建FeatureSet /// </summary> /// <param name="shpReader"></param> /// <param name="dbfReader"></param> /// <param name="recordNum"></param> /// <returns></returns> private static FeatureSet CreateFeatureSet(ShpReader shpReader, DbfReader dbfReader, int recordNum) { GeometryType geometryType = (GeometryType)shpReader.ShpHeader.ShapeType; var featureType = ShpUtil .GeometryType2FeatureType(geometryType); FeatureSet fs = new FeatureSet(featureType); IFeatureList features = new FeatureList(fs); for (int i = 0; i < recordNum; i++) { var spatialBytes = shpReader.GetNextRecord(); dbfReader.GetNextRow(); IGeometry geometry; switch (geometryType) { case GeometryType.Point: geometry = BytesToGeometry.CreatePoint(spatialBytes); break; case GeometryType.MultiPoint: geometry = BytesToGeometry.CreateMultipoint(spatialBytes); break; case GeometryType.PolyLine: geometry = BytesToGeometry.CreatePolyLine(spatialBytes); break; case GeometryType.Polygon: geometry = BytesToGeometry.CreatePolygon(spatialBytes); break; default: geometry = null; break; } IFeature feature = new Feature(geometry); features.Add(feature); } fs.Features.Set(features); fs.AttrTable = dbfReader.DbfTable; var header = shpReader.ShpHeader; //fs.Envelope = new Envelope(header.XMin, header.YMin, // header.XMax, header.YMax, // header.ZMin, header.ZMax); return(fs); }
/** * Instructs this state's Filter to process its input. * * @param env * Runtime processing environment */ public override FilterStateResult traverse(FilterEnv in_env) { FilterStateResult result = new FilterStateResult(); // clone a new environment: current_env = in_env.advance(); FeatureList output = filter.process(in_features, current_env); FilterState next = getNextState(); if (next != null) { if (output.Count > 0) { if (next is FeatureFilterState) { FeatureFilterState state = (FeatureFilterState)next; state.push(output); } else if (next is FragmentFilterState) { FragmentFilterState state = (FragmentFilterState)next; state.push(output); } else if (next is NodeFilterState) { NodeFilterState state = (NodeFilterState)next; state.push(output); } else if (next is CollectionFilterState) { CollectionFilterState state = (CollectionFilterState)next; state.push(output); } result = next.traverse(current_env); } else { result.set(FilterStateResult.Status.STATUS_NODATA, filter); } } // clean up in_features.Clear(); return(result); }
public Main() { _quoteDictionary = new Dictionary <string, Quote>(); FeatureList.Add(FeaturesT.SUPPORTS_REALTIME_OPTIONS_CHAIN); FeatureList.Add(FeaturesT.SUPPORTS_REALTIME_STOCK_QUOTE); FeatureList.Add(FeaturesT.SUPPORTS_STOCK_HISTORICAL_DATA); FeatureList.Add(FeaturesT.SUPPORTS_OPTIONS_HISTORICAL_DATA); FeatureList.Add(FeaturesT.SUPPORTS_HISTORICAL_VOLATILITY); FeatureList.Add(FeaturesT.SUPPORTS_INTEREST_RATE); // update server list ServerList.Add(Name); _B3Poviderconfig = new B3ProviderConfig(); _B3PoviderClient = new B3ProviderClient(_B3Poviderconfig); }
public Case(int caseID, string caseName, string caseDescription, FeatureList featureList) { _caseID = caseID; _caseName = caseName; _caseDescription = caseDescription; if (featureList != null) { _featureList = featureList; } else { _featureList = new FeatureList(); } }
override public FeatureList process(Feature input, FilterEnv env) { FeatureList output = new FeatureList(); //resolve the xlate shortcut Mogre.Matrix4 workingMatrix = Matrix; //TODO: this can go into process (FeatureList) instead of running for every feature.. if (TranslateScript != null) { ScriptResult r = env.getScriptEngine().run(TranslateScript, input, env); if (r.isValid()) { workingMatrix.MakeTrans(new Mogre.Vector3((float)r.asVec3().x, (float)r.asVec3().y, (float)r.asVec3().z)); } else { env.getReport().error(r.asString()); } } if (workingSrs != null || (workingMatrix != null && workingMatrix != Mogre.Matrix4.IDENTITY)) { //TODO foreach (Geometry shape in input.getGeometry()) //{ // if (workingMatrix != null && !workingMatrix.Equals(Mogre.Matrix4.IDENTITY)) // { // XformVisitor visitor = new XformVisitor(); // visitor.mat = workingMatrix; // shape.accept(visitor); // } // if (workingSrs != null && !(workingSrs.equivalentTo(env.getInputSRS()))) // { // workingSrs.transformInPlace(shape); // } //} if (workingSrs != null && !(workingSrs.equivalentTo(env.getInputSRS()))) { Geometry temp = GeometryTransform.TransformGeometry(input.getGeometry(), ((SharpMapSpatialReference)workingSrs).MathTransform); input.setGeometry(temp); //workingSrs.transformInPlace(input.getGeometry()); } } output.Add(input); return output; }
private void InitializeProperties() { Classes = new Dictionary<ClassType, IClass>(); Attacks = new AttackList(this); Saves = new SavesList(this); Hitpoints = new Hitpoints(); Equipment = new Equipment(this); Features = new FeatureList(); Skills = new SkillList(this); Experience = new Experience(this); }
override public FeatureList process(FeatureList input, FilterEnv env) { //first time through, establish a working SRS for output data. if (workingSrs == null) { //first try to use the terrain SRS if so directed: SpatialReference newOutSrs = UseTerrainSrs ? env.getTerrainSRS() : null; if (newOutSrs == null) { //failing that, see if we have an SRS in a resource: if (Srs == null && SrsScript != null) { //Console.WriteLine("Borrame" + SrsScript.getCode()); Srs = env.getSession().Resources.getSRS(SrsScript.getCode()); #if TODO_PH ScriptResult r = env.getScriptEngine().run(SrsScript, env); if (r.isValid()) { Srs = (env.getSession().Resources.getSRS(r.asString())); throw new NotImplementedException(); } else { env.getReport().error(r.asString()); } #endif } newOutSrs = Srs; } //set the "working" SRS that will be used for all features passing though this filter: workingSrs = newOutSrs != null ? newOutSrs : env.getInputSRS(); //LOCALIZE points arround a local origin (the working extent's centroid) if (workingSrs != null && Localize) { if (env.getCellExtent().getSRS().isGeographic() && env.getCellExtent().getWidth() > 179) { //NOP - no localization for big geog extent ... needs more thought perhaps } else { GeoPoint centroid0 = newOutSrs == null ? newOutSrs.transform(env.getCellExtent()).getCentroid() : env.getCellExtent().getCentroid(); //we do want the localizer point on the surface if possible: GeoPoint centroid = ClampToTerrain(centroid0, env); if (centroid == null) { centroid = centroid0; } Mogre.Matrix4 localizer = new Mogre.Matrix4(); //For geocentric datasets, we need a special localizer matrix: if (workingSrs.isGeocentric()) { localizer = workingSrs.getEllipsoid().createGeocentricInvRefFrame(centroid); localizer = localizer.Inverse(); } //For projected datasets, just a simple translation else { localizer.SetTrans(new Mogre.Vector3((float)centroid.X, (float)centroid.Y, (float)0.0)); } workingSrs = workingSrs.cloneWithNewReferenceFrame(localizer); } } } //we have to assing the output SRS on each pass if (workingSrs != null) { env.setOutputSRS(workingSrs); } return base.process(input, env); }
public void push(FeatureList input) { foreach (Feature i in input) if (i.hasShapeData()) in_features.Add(i); }
public override FeatureList process(FeatureList input, FilterEnv env) { FeatureList output = new FeatureList(); // HACER ALGO DEL ESTILO: if (transform == null) { //Create zone UTM 32N projection IProjectedCoordinateSystem utmProj = CreateUtmProjection(32); //Create geographic coordinate system (lets just reuse the CS from the projection) IGeographicCoordinateSystem geoCS = utmProj.GeographicCoordinateSystem; //Create transformation CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); // TODO DANI Mirar de donde viene este source y target ICoordinateTransformation Coordinatetransform = null;// TODO = ctFac.CreateFromCoordinateSystems(source, target); //cs string wkt = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]"; //ICoordinateSystem cs = SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt) as ICoordinateSystem; ICoordinateSystem cs = ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt) as ICoordinateSystem; //wgs84 GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84; //gcs CoordinateSystemFactory cFac = new ProjNet.CoordinateSystems.CoordinateSystemFactory(); //CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory(); //Create Bessel 1840 geographic coordinate system IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); //coordsys //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); Coordinatetransform = ctFac.CreateFromCoordinateSystems(gcs, coordsys);//gcsWGS84 -> gcenCsWGS84 //Apply transformation transform = Coordinatetransform.MathTransform; } SharpMap.Geometries.Point p = new SharpMap.Geometries.Point(30.0, 20.0); p = GeometryTransform.TransformPoint(p,transform); /*IMPORTANTE foreach (Feature feature in input) { feature.row.Geometry = GeometryTransform.TransformGeometry(feature.row.Geometry, transform); //feature.row.Geometry = GeometryTransform.TransformMultiPolygon(feature.row.Geometry, transform); } IMPORTANTE*/ foreach (Feature f in input) { output.Add(f);//output = input } // Cosas a cambiar: // Primero, la construccion del transform está siguiendo el ejemplo, pero hay que tener en cuenta los datos del xml y construirlo en consecuencia // Segundo, el filtro debe retornar una NUEVA lista, y no modificar la inicial. Ahora modifica los valores de la lista inicial // IMPORTANTE RETORNAR NUEVA LISTA OUTPUT <----------- FALTA POR HACER #if TODO // first time through, establish a working SRS for output data. if (working_srs == null) { // first try to use the terrain SRS if so directed: SpatialReference new_out_srs = getUseTerrainSRS() ? env.getTerrainSRS() : null; if (new_out_srs == null) { // failing that, see if we have an SRS in a resource: if (getSRS() == null && getSRSScript() != null) { ScriptResult r = env.getScriptEngine().run(getSRSScript(), env); if (r.isValid()) setSRS(env.getSession().getResources().getSRS(r.ToString())); else env.getReport().error(r.ToString()); } new_out_srs = srs; } // set the "working" SRS that will be used for all features passing though this filter: working_srs = new_out_srs != null ? new_out_srs : env.getInputSRS(); // LOCALIZE points around a local origin (the working extent's centroid) if (working_srs != null && getLocalize()) //&& env.getExtent().getArea() > 0.0 ) { if (env.getCellExtent().getSRS().isGeographic() && env.getCellExtent().getWidth() > 179.0) { //NOP - no localization for big geog extent ... needs more thought perhaps } else { GeoPoint centroid0 = new_out_srs != null ? new_out_srs.transform(env.getCellExtent().getCentroid()) : env.getCellExtent().getCentroid(); // we do want the localizer point on the surface if possible: GeoPoint centroid = clampToTerrain(centroid0, env); if (centroid == null) centroid = centroid0; Matrixd localizer; // For geocentric datasets, we need a special localizer matrix: if (working_srs.isGeocentric()) { localizer = working_srs.getEllipsoid().createGeocentricInvRefFrame(centroid); localizer.invert(localizer); } // For projected datasets, just a simple translation: else { localizer = osg.Matrixd.translate(-centroid); } working_srs = working_srs.cloneWithNewReferenceFrame(localizer); } } } // we have to assign the output SRS on each pass if (working_srs != null) { env.setOutputSRS(working_srs); } return base.process(input, env); #endif //throw new NotImplementedException(); if (successor != null) { if (successor is FeatureFilter) { FeatureFilter filter = (FeatureFilter)successor; FeatureList l = filter.process(output, env); } else if (successor is FragmentFilter) { FragmentFilter filter = (FragmentFilter)successor; FragmentList l = filter.process(output, env); } } return output; }
override public FeatureList process(FeatureList input, FilterEnv env) { foreach (Feature feature in input) { CoordinateSystemFactory csf = new CoordinateSystemFactory(); ICoordinateSystem cssource = csf.CreateFromWkt(((SharpMapSpatialReference)feature.getGeometry().SpatialReference).CoordinateSystem.WKT); ICoordinateSystem cstarget; if (translateScript != null) { //Console.WriteLine(Registry.instance().GetEngine("Python").run(TranslateScript).asString()); cstarget = csf.CreateFromWkt(Registry.instance().GetEngine("Python").run(TranslateScript).asString()); } else { cstarget = csf.CreateFromWkt(env.getInputSRS().WKT); } CoordinateTransformationFactory ctf = new CoordinateTransformationFactory(); ICoordinateTransformation ct = ctf.CreateFromCoordinateSystems(cssource, cstarget); //if (feature.getGeometry().GeometryType == GeometryType2.Point) //{ // Point p = (Point)feature.getGeometry(); //GeometryTransform.TransformPoint(feature, ct.MathTransform); Geometry geom = feature.getGeometry(); Geometry geomRst = GeometryTransform.TransformGeometry(geom, ct.MathTransform); feature.setGeometry(geomRst); //} } return input; }
/** * Processes a single Feature. * * @param input * Individual Feature to process. * @param env * Runtime processing environment. * @return * A collection of Feature instances. The default implementation * of this method just returns the input in a list. */ public virtual FeatureList process(Feature input, FilterEnv env) { FeatureList output = new FeatureList(); output.Add(input); return output; }
// FragmentFilter overrides public override FragmentList process(FeatureList input, FilterEnv env) { FragmentList output = new FragmentList(); //cuidado con las entidades dentro del for int i = 0; Vector3 scale; Vector3 distanceScale; Vector3 mScale = new Vector3 (1,1,1); float lWidth = 1; if (Scale != null) { scale = Registry.instance().GetEngine("Python").run(Scale).asVec3(); } else { scale = new Vector3(1, 1, 1); } if (CoordScale != null) { distanceScale = Registry.instance().GetEngine("Python").run(CoordScale).asVec3(); } else { distanceScale = new Vector3(1, 1, 1); } if (LineWidth != null) { lWidth = Registry.instance().GetEngine("Python").run(LineWidth).asFloat(); } if (MaterialScale != null) { mScale = Registry.instance().GetEngine("Python").run(MaterialScale).asVec3(); } SceneNode nodeIni = point3d(env.getName(), i, 0, 0, 0, null, env.getSceneMgr()); #if ESCALA_NODO_INICIAL if (Scale != null) { nodeIni.SetScale(Registry.instance().GetEngine("Python").run(Scale).asVec3()); } if (coordScale != null) { Vector3 vec3 = Registry.instance().GetEngine("Python").run(Scale).asVec3(); nodeIni.SetPosition(nodeIni.Position.x * vec3.x, nodeIni.Position.y * vec3.y, nodeIni.Position.z * vec3.z); #if TRACE_BUILDGEOMFILTER System.Console.WriteLine("(" + n.Position.x + "," + n.Position.y + ")"); #endif } #endif Fragment fIni = new Fragment(nodeIni); output.Add(fIni); foreach (Feature feature in input) { //if type of features is Point if (feature.row.Geometry is SharpMap.Geometries.Point) { SharpMap.Geometries.Point p = (SharpMap.Geometries.Point)feature.row.Geometry; i++; SceneNode n = point3d(env.getName(), i, (float)p.X, (float)p.Y, 0, nodeIni, env.getSceneMgr()); n.SetScale(scale); n.SetPosition(n.Position.x * distanceScale.x, n.Position.y * distanceScale.y, n.Position.z * distanceScale.z); Fragment f = new Fragment(n); output.Add(f); } //if type of features is Polygon else if (feature.row.Geometry is SharpMap.Geometries.Polygon) { SharpMap.Geometries.Polygon polygon = (SharpMap.Geometries.Polygon)feature.row.Geometry; ManualObject polygonNode = null; if (polygonNode == null) { polygonNode = env.getSceneMgr().CreateManualObject(env.getName() + "Node_" + i); MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(polygonNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); int numVertices = polygon.ExteriorRing.NumPoints/*/10+1*/; int numValores = 3; double[][] data = new double[numVertices][]; for (int j = 0; j < numVertices; j++) { data[j] = new double[numValores]; } int k = 0; //1 polygon = N vertices foreach (SharpMap.Geometries.Point point in polygon.ExteriorRing.Vertices) { //if (k % 10 == 0) { data[k/*/10*/][0] = point.X; data[k/*/10*/][1] = point.Y; data[k/*/10*/][2] = 0; } k++; //SceneNode n = point3d(env.getName()+i+k, k + 10, (float)point.X * 10.0f, (float)point.Y * 10.0f, 0, nodeIni, env.getSceneMgr()); } for (int j = 0; j < data.GetLength(0); j++) { Glu.gluTessVertex(data[j], 0, new Vector3((float)(data[j][1] * distanceScale.y), (float)(data[j][2] * distanceScale.z), (float)(data[j][0] * distanceScale.x))); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); nodeIni.AttachObject(polygonNode); } i++; } //if type of features is MultiPolygon else if (feature.row.Geometry is SharpMap.Geometries.MultiPolygon) { SharpMap.Geometries.MultiPolygon mp = (SharpMap.Geometries.MultiPolygon)feature.row.Geometry; // 1 MultiPolygon = N polygon foreach (SharpMap.Geometries.Polygon polygon in mp.Polygons) { ManualObject polygonNode = null; if (polygonNode == null) { polygonNode = env.getSceneMgr().CreateManualObject(env.getName() + "Node_" + i); MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(polygonNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); int numVertices = polygon.ExteriorRing.NumPoints; int numValores = 3; double[][] data = new double[numVertices][]; for (int j = 0; j < numVertices; j++) { data[j] = new double[numValores]; } int k = 0; //1 polygon = N vertices foreach (SharpMap.Geometries.Point point in polygon.ExteriorRing.Vertices) { data[k][0] = point.X; data[k][1] = point.Y; data[k][2] = 0; k++; //SceneNode n = point3d(env.getName(), i, (float)point.X, (float)point.Y, 0, nodeIni, env.getSceneMgr()); } for (int j = 0; j < data.GetLength(0); j++) { Glu.gluTessVertex(data[j], 0, new Vector3(((float)data[j][1]) * distanceScale.y, ((float)data[j][2]) * distanceScale.z, ((float)data[j][0]) * distanceScale.x)); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); nodeIni.AttachObject(polygonNode); } i++; } } //if type of features is Line else if (feature.row.Geometry is SharpMap.Geometries.ILineal/*SharpMap.Geometries.LineString*/) { System.Collections.Generic.List<SharpMap.Geometries.ILineal> lineas = new System.Collections.Generic.List<SharpMap.Geometries.ILineal>(); if (feature.row.Geometry is SharpMap.Geometries.MultiLineString) { foreach (SharpMap.Geometries.LineString l in ((SharpMap.Geometries.MultiLineString)(feature.row.Geometry)).LineStrings) { lineas.Add(l); } } else { lineas.Add((SharpMap.Geometries.ILineal)(feature.row.Geometry)); } foreach (SharpMap.Geometries.ILineal line in lineas) { ManualObject lineNode = env.getSceneMgr().CreateManualObject("line" + i); //MaterialPtr material = MaterialManager.Singleton.Create(nameMaterial, //ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); //material.GetTechnique(0).GetPass(0).VertexColourTracking = // (int)TrackVertexColourEnum.TVC_AMBIENT; //material.GetTechnique(0).GetPass(0).SetDepthBias(100); //material.GetTechnique(0).GetPass(0).LightingEnabled = false; int nSeg = 5; // Number of segments on the cap or join pieces BufferParameters param = new BufferParameters(nSeg, BufferParameters.BufferEndCapStyle.CapRound, BufferParameters.BufferJoinStyle.JoinRound, 2); IGeometryFactory<Coord> geometryFactory = new GeometryFactory<Coord>(new CoordSeqFac(new CoordFac(PrecisionModelType.DoubleFloating))); //IWktGeometryReader<Coord> reader = geometryFactory.WktReader; //string txt = feature.row.Geometry.AsText(); ILineString line1 = (ILineString)GeometryConverter.ToNTSGeometry((SharpMap.Geometries.LineString)line, geometryFactory); // (ILineString<Coord>)reader.Read(txt); IGeometry coordBuffer = line1.Buffer(lWidth, param); ICoordinateSequence coords = coordBuffer.Coordinates; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(lineNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); foreach (Coord coord in coords) { double[] data = new double[] { coord.X * distanceScale.x, coord.Y * distanceScale.y, (double.IsNaN(coord.Z) ? 0 : coord.Z) * distanceScale.z }; Glu.gluTessVertex(data, 0, new Vector3((float)data[1], (float)data[2], (float)data[0])); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); i++; nodeIni.AttachObject(lineNode); } if ((feature.row.Geometry is SharpMap.Geometries.Polygon) | (feature.row.Geometry is SharpMap.Geometries.MultiPolygon)) { Fragment f = new Fragment(nodeIni); output.Add(f); } } } i = 0;//breakpoint /*foreach (Fragment fragment in output) { fragment.Node.Scale(0,0,0); }*/ #if TODO // if features are arriving in batch, resolve the color here. // otherwise we will resolve it later in process(feature,env). is_batch = input.Count > 1; batch_feature_color = overall_color; if (is_batch && getColorScript() != null) { ScriptResult r = env.getScriptEngine().run(getColorScript(), env); if (r.isValid()) batch_feature_color = r.asVec4(); else env.getReport().error(r.asString()); } return base.process(input, env); #endif //throw new NotImplementedException(); if (successor != null) { if (successor is FeatureFilter) { FeatureFilter filter = (FeatureFilter)successor; FeatureList l = filter.process(input, env); //FeatureList l = successor.process(input, env); } else if (successor is FragmentFilter) { FragmentFilter filter = (FragmentFilter)successor; FragmentList l = filter.process(output, env); } } return output; }
/// <summary> /// Constructor that also accepts a progres handler to show the progress of loading the values into memory. /// </summary> /// <param name="filename">The filename to open.</param> /// <param name="progressHandler">Any valid implementation of the IProgressHandler interface.</param> public ShapefileFeatureSet(string filename, IProgressHandler progressHandler) { //Fields = new Dictionary<string, Field>(); _columns = new List<Field>(); DataTable = new System.Data.DataTable(); Features = new FeatureList(this); // Since they have passed a filename go ahead and open it Filename = filename; FeatureType = FeatureTypes.Unspecified; // this will get set when queried the first time Name = Path.GetFileNameWithoutExtension(filename); Open(progressHandler); }
public override FeatureList process(Feature input, FilterEnv env) { FeatureList output = new FeatureList(); if (transform != null && !transform.Identity()) { foreach (GeoShape shape in input.getShapes()) { XformVisitor visitor = new XformVisitor(); visitor.trans = transform; shape.accept(visitor); } } output.Add(input); return output; #if TODO // resolve the xlate shortcut Matrix working_matrix = xform_matrix; // TODO: this can go into process(FeatureList) instead of running for every feature.. if (getTranslateScript() != null) { ScriptResult r = env.getScriptEngine().run(getTranslateScript(), input, env); if (r.isValid()) working_matrix = Matrix.translate(r.asVec3()); else env.getReport().error(r.asString()); } if (working_srs != null || (working_matrix != null && !working_matrix.IsIdentity)) { foreach (GeoShape shape in input.getShapes()) { if (working_matrix != null && !working_matrix.IsIdentity) { XformVisitor visitor; visitor.mat = working_matrix; shape.accept(visitor); } if (working_srs != null && !working_srs.equivalentTo(env.getInputSRS())) { working_srs.transformInPlace(shape); } } } output.Add(input); return output; #endif throw new NotImplementedException(); }
public virtual void preMeter(FeatureList features, FilterEnv env) { }
public override FeatureList process(FeatureList input, FilterEnv env) { FeatureList output = new FeatureList(); //Boolean encontrado = false; SharpMap.Geometries.BoundingBox boundingBox = new SharpMap.Geometries.BoundingBox(longitudeMin,latitudeMin,longitudeMax,latitudeMax); foreach (Feature feature in input) { //if type of features is Point if (feature.row.Geometry is SharpMap.Geometries.Point) { SharpMap.Geometries.Point p = (SharpMap.Geometries.Point)feature.row.Geometry; if (boundingBox.Contains(p.GetBoundingBox())) { output.Add(feature); } } //if type of features is Polygon else if (feature.row.Geometry is SharpMap.Geometries.Polygon) { SharpMap.Geometries.Polygon polygon = (SharpMap.Geometries.Polygon)feature.row.Geometry; if (boundingBox.Contains(polygon.GetBoundingBox())) { output.Add(feature); } } //if type of features is MultiPolygon else if (feature.row.Geometry is SharpMap.Geometries.MultiPolygon) { SharpMap.Geometries.MultiPolygon mp = (SharpMap.Geometries.MultiPolygon)feature.row.Geometry; SharpMap.Geometries.BoundingBox bb = mp.GetBoundingBox(); if (boundingBox.Contains(bb)) { output.Add(feature); } } } if (successor != null) { if (successor is FeatureFilter) { FeatureFilter filter = (FeatureFilter)successor; FeatureList l = filter.process(output, env); } else if (successor is FragmentFilter) { FragmentFilter filter = (FragmentFilter)successor; FragmentList l = filter.process(output, env); } } return output; }
// FragmentFilter overrides protected virtual FragmentList process(FeatureList input, FilterEnv env) { // load and cache the font if (!string.IsNullOrEmpty(getFontName()) && !font.valid()) { font = osgText.readFontFile(getFontName()); } return base.process(input, env); }