public ActionResult <string> AddHotelCommand([FromBody] Hotel hotel) { var result = HotelHelper.AddHotel(hotel).ToString(); ProjectionHelper.ProjectRooms(); return(result); }
public ActionResult <string> RemoveHotelCommand(string hotelId) { var result = HotelHelper.RemoveHotel(hotelId).ToString(); ProjectionHelper.TruncateAndProjectRooms(); return(result); }
public ActionResult <string> AddRoomCommand([FromBody] Room room) { var result = HotelHelper.AddRoom(room).ToString(); ProjectionHelper.ProjectRooms(); return(result); }
protected virtual void DataArrived(IEnumerable <IFeature> features, object state) { //the data in the cache is stored in the map projection so it projected only once. if (features == null) { throw new ArgumentException("argument features may not be null"); } features = features.ToList(); if (ProjectionHelper.NeedsTransform(Transformation, CRS, DataSource.CRS)) { foreach (var feature in features.Where(feature => !(feature.Geometry is Raster))) { feature.Geometry = Transformation.Transform(DataSource.CRS, CRS, feature.Geometry); } } Sets.Add(new FeatureSets { TimeRequested = (long)state, Features = features }); //Keep only two most recent sets. The older ones will be removed Sets = Sets.OrderByDescending(c => c.TimeRequested).Take(NumberOfFeaturesReturned).ToList(); IsFetching = false; OnDataChanged(new DataChangedEventArgs(null, false, null, LayerName)); if (NeedsUpdate) { StartNewFetch(NewExtent, NewResolution); } }
/// <summary> /// Reprojects layer source, including shapefiles, images and grids. /// </summary> public TestingResult Reproject(ILayerSource layer, out ILayerSource newLayer, ISpatialReference projection, TesterReportForm report) { if (layer.SeekSubstituteFile(projection, out newLayer)) { return(TestingResult.Substituted); } string newFilename = ProjectionHelper.FilenameWithProjectionSuffix(layer.Filename, layer.Projection, projection); newFilename = GetSafeNewName(newFilename); switch (layer.LayerType) { case LayerType.Shapefile: newLayer = Reproject(layer as IFeatureSet, projection, newFilename); break; case LayerType.Grid: newLayer = Reproject(layer as GridSource, projection, newFilename); break; case LayerType.Image: newLayer = Reproject(layer as BitmapSource, projection, newFilename); break; } return(newLayer != null ? TestingResult.Ok : TestingResult.Error); }
public override void Draw(SpriteBatch sb) { if (startBody != null) { SpriteHelper.DrawLine(sb, ProjectionHelper.FarseerToPixel(startBody.GetWorldPoint(startBodyLocal)), game.inputManager.inputHelper.MousePosition, 2f, Color.Blue); } }
public ActionResult <string> ChangePriceCommand(string roomId, [FromBody] Room room) { var result = RoomHelper.SetRoomPrice(roomId, room).ToString(); ProjectionHelper.TruncateAndProjectRooms(); return(result); }
// public static methods public static AstPipeline Translate(TranslationContext context, MethodCallExpression expression) { var method = expression.Method; var arguments = expression.Arguments; if (method.Is(QueryableMethod.Select)) { var sourceExpression = arguments[0]; var pipeline = ExpressionToPipelineTranslator.Translate(context, sourceExpression); var sourceSerializer = pipeline.OutputSerializer; var selectorLambda = ExpressionHelper.UnquoteLambda(arguments[1]); if (selectorLambda.Body == selectorLambda.Parameters[0]) { return(pipeline); // ignore identity projection: Select(x => x) } var selectorTranslation = ExpressionToAggregationExpressionTranslator.TranslateLambdaBody(context, selectorLambda, sourceSerializer, asRoot: true); var(projectStage, projectionSerializer) = ProjectionHelper.CreateProjectStage(selectorTranslation); pipeline = pipeline.AddStages(projectionSerializer, projectStage); return(pipeline); } throw new ExpressionNotSupportedException(expression); }
private void Explode() { if (Alive) { Vector2 explosionPoint = body.Position; world.RemoveBody(body); world.ProcessChanges(); body = null; CuttingTools.Cut(world, explosionPoint + new Vector2(2, 2), explosionPoint - new Vector2(2, 2), 0.01f); //world.ProcessChanges(); CuttingTools.Cut(world, explosionPoint + new Vector2(-2, 2), explosionPoint - new Vector2(-2, 2), 0.01f); //world.ProcessChanges(); Explosion e = new Explosion(world); e.Activate(explosionPoint, 2, 10); Alive = false; pivot = null; Vector2 screenLoc = ProjectionHelper.FarseerToPixel(explosionPoint); ParticleEffectManager.explosionEffect.Trigger(screenLoc); } }
public ActionResult <string> DirtyCommand(string roomId) { var result = RoomHelper.SetDirtyRoom(roomId).ToString(); ProjectionHelper.TruncateAndProjectRooms(); return(result); }
/// <summary> /// Creates a new filename and saves the content from the current BitmapGetter to the /// file format. This relies on the DataManager and will only be successful for /// formats supported by the write format possibility. This will not update this raster /// </summary> /// <param name="fileName">The string fileName to write to</param> /// <param name="progressHandler">The progress handler for creating a new bitmap.</param> /// <param name="bandType">The band type ot use.</param> public void ExportBitmap(string fileName, IProgressHandler progressHandler, ImageBandType bandType) { int rows = DataSet.NumRowsInFile; int cols = DataSet.NumColumnsInFile; IImageData result = DataManager.DefaultDataManager.CreateImage(fileName, rows, cols, false, progressHandler, bandType); int numBlocks = 1; if (rows * cols > 8000 * 8000) { numBlocks = Convert.ToInt32(Math.Ceiling(8000 * 8000 / (double)cols)); } int blockRows = (8000 * 8000) / cols; ProjectionHelper ph = new ProjectionHelper(DataSet.Extent, new Rectangle(0, 0, cols, rows)); for (int iblock = 0; iblock < numBlocks; iblock++) { int rowCount = blockRows; if (iblock == numBlocks - 1) { rowCount = rows - blockRows * iblock; } Rectangle r = new Rectangle(0, iblock * blockRows, cols, rowCount); Bitmap block = BitmapGetter.GetBitmap(ph.PixelToProj(r), r); result.WriteBlock(block, 0, iblock * blockRows); } }
/// <summary> /// Adds the specified property to the projection list. /// </summary> /// <param name="list"> /// The projection list. /// </param> /// <param name="property"> /// The property. /// </param> /// <param name="data"> /// A <see cref="QueryHelperData" /> instance. /// </param> /// <typeparam name="TSource"> /// The <see cref="System.Type" /> of the source entity. /// </typeparam> /// <typeparam name="TProperty"> /// The <see cref="System.Type" /> of the property. /// </typeparam> /// <returns> /// The <see cref="ProjectionList" /> instance. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="list" /> is null. /// </exception> public static ProjectionList AddProperty <TSource, TProperty> ( this ProjectionList list, Expression <Func <TSource, TProperty> > property, QueryHelperData data ) { if (list == null) { throw new ArgumentNullException("list"); } IProjection projection = ProjectionHelper.GetProjection(property, data); string alias = null; var propertyProjection = projection as IPropertyProjection; if (propertyProjection != null) { alias = propertyProjection.PropertyName; } list.Add(projection, alias); return(list); }
public ActionResult <string> OccupyCommand(string roomId, [FromBody] Room room) { var result = RoomHelper.AddGuestToEmptyRoom(roomId, room).ToString(); ProjectionHelper.TruncateAndProjectRooms(); return(result); }
public override void HandleInput() { InputHelper input = game.inputManager.inputHelper; if (input.IsNewButtonPress(MouseButtons.LeftButton)) { Vector2 position = ProjectionHelper.PixelToFarseer(input.MousePosition); List <Fixture> list = game.farseerManager.world.TestPointAll(position); if (list.Count > 0) { if (startBody == null) { startBody = list[0].Body; startBodyLocal = startBody.GetLocalPoint(position); } else { Body endBody = list[0].Body; Vector2 endBodyLocal = endBody.GetLocalPoint(position); RopeJoint j = new RopeJoint(startBody, endBody, startBodyLocal, endBodyLocal); j.CollideConnected = true; game.farseerManager.world.AddJoint(j); FormManager.Property.setSelectedObject(j); startBody = null; } } } }
public override void Update() { ragdollPixel = ProjectionHelper.FarseerToPixel(game.ragdollManager.ragdoll.Body.Position); mePixel = ProjectionHelper.FarseerToPixel(body.Position); base.Update(); }
/// <inheritdoc /> public virtual TQuery GroupBy(Expression <Func <TSource, object> > property) { if (property != null) { IProjection projection = ProjectionHelper .GetProjection ( property.Body, new HelperContext(Data, property, HelperType.GroupBy) ); if (projection != null) { if (projection.IsGrouped || projection.IsAggregate) { throw new InvalidOperationException( "Cannot use an aggregate or grouped projection with GroupBy"); } GroupBys.Add(new FqGroupByProjection(projection, false)); } } return(Query); }
protected void StartNewFetch(BoundingBox extent, double resolution) { IsFetching = true; NeedsUpdate = false; var newExtent = new BoundingBox(extent); if (Transformation != null && !string.IsNullOrWhiteSpace(CRS)) { DataSource.CRS = CRS; } if (ProjectionHelper.NeedsTransform(Transformation, CRS, DataSource.CRS)) { if (Transformation != null && Transformation.IsProjectionSupported(CRS, DataSource.CRS) == true) { newExtent = Transformation.Transform(CRS, DataSource.CRS, extent); } } var fetcher = new FeatureFetcher(newExtent, resolution, DataSource, DataArrived, DateTime.Now.Ticks); Task.Run(() => fetcher.FetchOnThread()); }
private void SetupRendering() { farseerView = createFarseerView(); ProjectionHelper.Update(farseerView); spriteBatchTransformation = farseerView * spriteBatchProjection; }
private void ResetTransform() { farseerProjection = getFarseerProjection(); spriteBatchProjection = farseerProjection * Matrix.Invert(getScreenProjection()); farseerManager.setProjection(farseerProjection); ProjectionHelper.Init(GraphicsDevice.Viewport, farseerProjection); }
/// <inheritdoc /> public override IProjection Project ( Expression expression, HelperContext context ) { return(ProjectionHelper.GetProjection(((LambdaExpression)expression).Body, context)); }
private BoundingBox Transform(BoundingBox extent) { if (ProjectionHelper.NeedsTransform(Transformation, CRS, DataSource.CRS)) { return(Transformation.Transform(CRS, DataSource.CRS, extent.Copy())); } return(extent); }
private void Mouse() { InputHelper inputHelper = game.inputManager.inputHelper; Vector2 position = ProjectionHelper.PixelToFarseer(inputHelper.MousePosition); if (inputHelper.IsNewButtonPress(MouseButtons.RightButton)) { Fixture f = game.farseerManager.world.TestPoint(position); FormManager.Property.setSelectedObject(f); if (f != null) { FormManager.Property.setPendingObjects(new List <object> { f.Body }); } } if (dragging && savedFixture != null) { Vector2 lastPosition; if (prevWorldLoc.X == 0 && prevWorldLoc.Y == 0) { lastPosition = new Vector2(inputHelper.LastMouseState.X, inputHelper.LastMouseState.Y); } else { lastPosition = ProjectionHelper.FarseerToPixel(prevWorldLoc); } prevWorldLoc = position; lastPosition = ProjectionHelper.PixelToFarseer(lastPosition); Vector2 dragVec = position - lastPosition; if (!FormManager.Property.tryGroupDrag(savedFixture, dragVec)) { savedFixture.Body.Position += position - lastPosition; } } if (inputHelper.IsOldButtonPress(MouseButtons.LeftButton)) { MouseUp(position); } else if (inputHelper.IsNewButtonPress(MouseButtons.LeftButton)) { MouseDown(position); } if (_fixedMouseJoint != null) { _fixedMouseJoint.WorldAnchorB = position; } }
public void Draw() { Vector2 aim = AimVector; Vector2 screenLoc = ProjectionHelper.FarseerToPixel(body.Position - aim * .5f); ParticleEffectManager.flameEffect[0].ReleaseImpulse = aim * -60; ParticleEffectManager.flameEffect[0].ReleaseScale.Value = 40; ParticleEffectManager.flameEffect.Trigger(screenLoc); }
// public static methods public static AstPipeline Translate(TranslationContext context, MethodCallExpression expression) { var method = expression.Method; var arguments = expression.Arguments; if (method.Is(QueryableMethod.Join)) { var outerExpression = arguments[0]; var pipeline = ExpressionToPipelineTranslator.Translate(context, outerExpression); var outerSerializer = pipeline.OutputSerializer; var wrapOuterStage = AstStage.Project( AstProject.Set("_outer", AstExpression.Var("ROOT")), AstProject.ExcludeId()); var wrappedOuterSerializer = WrappedValueSerializer.Create("_outer", outerSerializer); var innerExpression = arguments[1]; var(innerCollectionName, innerSerializer) = innerExpression.GetCollectionInfo(containerExpression: expression); var outerKeySelectorLambda = ExpressionHelper.UnquoteLambda(arguments[2]); var localFieldPath = outerKeySelectorLambda.GetFieldPath(context, wrappedOuterSerializer); var innerKeySelectorLambda = ExpressionHelper.UnquoteLambda(arguments[3]); var foreignFieldPath = innerKeySelectorLambda.GetFieldPath(context, innerSerializer); var lookupStage = AstStage.Lookup( from: innerCollectionName, match: new AstLookupStageEqualityMatch(localFieldPath, foreignFieldPath), @as: "_inner"); var unwindStage = AstStage.Unwind("_inner"); var resultSelectorLambda = ExpressionHelper.UnquoteLambda(arguments[4]); var root = AstExpression.Var("ROOT", isCurrent: true); var outerParameter = resultSelectorLambda.Parameters[0]; var outerField = AstExpression.GetField(root, "_outer"); var outerSymbol = context.CreateSymbol(outerParameter, outerField, outerSerializer); var innerParameter = resultSelectorLambda.Parameters[1]; var innerField = AstExpression.GetField(root, "_inner"); var innerSymbol = context.CreateSymbol(innerParameter, innerField, innerSerializer); var resultSelectorContext = context.WithSymbols(outerSymbol, innerSymbol); var resultSelectorTranslation = ExpressionToAggregationExpressionTranslator.Translate(resultSelectorContext, resultSelectorLambda.Body); var(projectStage, newOutputSerializer) = ProjectionHelper.CreateProjectStage(resultSelectorTranslation); pipeline = pipeline.AddStages( newOutputSerializer, wrapOuterStage, lookupStage, unwindStage, projectStage); return(pipeline); } throw new ExpressionNotSupportedException(expression); }
public IProjection Project ( Expression expression, HelperContext context ) { var methodCall = (MethodCallExpression)expression; return(ProjectionHelper.GetProjection(methodCall.Object, context)); }
/// <inheritdoc /> public override IProjection Project ( Expression expression, HelperContext context ) { var memberInit = (MemberInitExpression)expression; var list = Projections.ProjectionList(); var newProjection = ProjectionHelper.GetProjection(memberInit.NewExpression, context) as ProjectionList; if (newProjection != null) { for (int i = 0; i < newProjection.Length; i++) { list.Add(newProjection[i]); } } foreach (MemberBinding memberBinding in memberInit.Bindings) { var memberAssigment = memberBinding as MemberAssignment; if (memberAssigment != null) { IProjection projection = ProjectionHelper.GetProjection(memberAssigment.Expression, context); var innerList = projection as ProjectionList; if (innerList != null) { for (int i = 0; i < innerList.Length; i++) { list.Add(innerList[i]); } } else { string member = memberAssigment.Member.Name; list.Add(new FqAliasProjection(projection, member)); if (!context.Data.Mappings.ContainsKey(member)) { context.Data.Mappings.Add(member, projection); } } } } return(list); }
private Matrix createFarseerView() { // All vectors here are in farseer coordinates. Vector2 center; float horizontalBound; float verticalBound; if (ragdollManager.CameraShouldTrack) { center = ragdollManager.getRagdollCenter(); horizontalBound = 10; verticalBound = 10; } else { center = ProjectionHelper.PixelToFarseer(inputManager.inputHelper.MousePosition); horizontalBound = 25; verticalBound = 15; } float top = -farseerView.Translation.Y + verticalBound; float bottom = -farseerView.Translation.Y - verticalBound; float left = -farseerView.Translation.X - horizontalBound; float right = -farseerView.Translation.X + horizontalBound; Vector3 translate = new Vector3(); if (center.X < left) { translate.X = center.X - left; } else if (center.X > right) { translate.X = center.X - right; } if (center.Y > top) { translate.Y = center.Y - top; } else if (center.Y < bottom) { translate.Y = center.Y - bottom; } translate.X = CurveFunc(translate.X, 20); translate.Y = CurveFunc(translate.Y, 20); Matrix m = Matrix.CreateTranslation(farseerView.Translation.X - translate.X, farseerView.Translation.Y - translate.Y, 0); return(m); }
/// <inheritdoc /> public override IProjection Project(Expression expression, HelperContext context) { var condition = (ConditionalExpression)expression; return(Projections .Conditional ( RestrictionHelper.GetCriterion(condition.Test, context), ProjectionHelper.GetProjection(condition.IfTrue, context), ProjectionHelper.GetProjection(condition.IfFalse, context) )); }
private static string CreateSr(string crs) { if (crs.StartsWith(ProjectionHelper.EsriStringPrefix)) { return("{\"wkt\":\"" + crs.Substring(ProjectionHelper.EsriStringPrefix.Length).Replace("\"", "\\\"") + "\"}"); } if (crs.StartsWith(ProjectionHelper.EpsgPrefix)) { return(ProjectionHelper.ToEpsgCode(crs).ToString()); } throw new Exception("crs type not supported"); }
public override void Draw(SpriteBatch sb) { //sb.Draw(dragTex, ProjectionHelper.FarseerToPixel(worldStart), null, Color.White, 0, new Vector2(dragTex.Width / 2, dragTex.Height / 2), if (drawing) { SpriteHelper.DrawCircle(sb, ProjectionHelper.FarseerToPixel(worldStart), GetPixelDragArea().diagonal * 2, new Color(100, 100, 255, 100)); } //if (drawing) // sb.Draw(dragTex, GetPixelDragArea().intRectangle, new Color(100, 100, 255, 100)); }